No new records

  • Thread starter Thread starter nybaseball22
  • Start date Start date
N

nybaseball22

Hello. I have a subform in a form that I use to add records. Is
there a way to keep this subform from sorting through all the records
in the query it pulls from? I have the query use a query with an
autonumber and have set it to Allow Adds:No. Not sure why it still
scrolls through records.

Thanks
 
Hello. I have a subform in a form that I use to add records. Is
there a way to keep this subform from sorting through all the records
in the query it pulls from? I have the query use a query with an
autonumber and have set it to Allow Adds:No. Not sure why it still
scrolls through records.


I'm not sure what you meant. Are you using the subform to add records, or
the form? What is supposed to be shown on the subform, and what is being
shown that is not supposed to be shown?
 
Hello. I have a subform in a form that I use to add records. Is
there a way to keep this subform from sorting through all the records
in the query it pulls from? I have the query use a query with an
autonumber and have set it to Allow Adds:No. Not sure why it still
scrolls through records.

Thanks

I'm sorry, this makes no sense.

You're using a subform to add records.
You have it set to Allow Adds: No.

The subform will display the records in its Recordsource. If you don't want to
display those records, change the recordsource!

Please step back a bit and try to explain what you have, and what you would
like to be able to do.

John W. Vinson [MVP]
 
When I typed this, it made perfect sense. I look back and realize it
is very vague. Sorry. This may seem a little long winded, but here
are the details.

I have a form where I put bills in for a company and break them down
into some detail. There are bills for cellphones, electricity,
heating oil, and cable. I have a main form "BillsNew" that has fields
that I choose the payee from a combo box. After I make the choice, a
vlookup runs and pulls from another table the type of bill and some
other various details. I have code that runs to open a subform based
on the information in one of the vlookup fields. This code runs on the
Form's OnCurrent and the field's (Payee) AfterUpdate. The form's
source is the main table "BillsMain".

Now for the subform. The subform's source is a query "subBillsAll".
It opens one of 4 subforms based on the vlookup field "Type", which is
oil, cable, etc. After the subform opens, the code applies a filter
to pull the record I am viewing in the main form into the fields on
the subform. The strings in the code are in the payee field and a
AutoNumber field. I will place the code below.

The problem is - it seems to be pulling the correct informtion, but if
I tab through all the information on the form, it moves to the next
record. I want to prevent this, as I have done with other forms by
changing the AllowAdds to No. However, this is not working on this
subform.

Note: I have everything setup this way because there are many fields
that do not apply to all records, so this is the cleanest way. I plan
to use the subforms in about 4 different forms, so that is why I have
them open to all records and then apply a filter.

Please let me know if any of this is unclear. Here is the code, and
thank you very much for bearing with me.

If IsNull(Me.[Payee]) Then
Me.SubBillsChild.SourceObject = "subBillsMain"
Else
Select Case Me.Type
Case "Electricity"
Me.SubBillsChild.SourceObject = "subBillsElectricity"
DoCmd.ApplyFilter "subBillsNew", ""
Case "Oil"
Me.SubBillsChild.SourceObject = "subBillsOil"
DoCmd.ApplyFilter "subBillsNew", ""
Case "Cable/Telephone/Internet"
Me.SubBillsChild.SourceObject = "subBillsCable"
DoCmd.ApplyFilter "subBillsNew", ""
Case "Cellphone"
Me.SubBillsChild.SourceObject = "subBillsCell"
DoCmd.ApplyFilter "subBillsNew", ""
Case Else
Me.SubBillsChild.SourceObject = "subBillsMain"
DoCmd.ApplyFilter "subBillsNew", ""
End Select
End If
 
Back
Top