N
nybaseball22
This is a repost of an original message posted January 18th. I think
the issue died with those that were looking at it, so I am posting
hoping for some help.
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
the issue died with those that were looking at it, so I am posting
hoping for some help.
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