form filters

B

bradd

I have Form A which has a combobox and a subform. The subform (sFormA)
data is based on the combo box selection and is a datasheet view.

I have another form (Form B). Here's the problem: I want to be able to
doubleclick on a record in sFormA and then open Form B filtered by the
record in sFormA. The field I wish to filter by is in sFormA is VehID.
This field is also in Form B.

Any suggestions?
 
G

Guest

Bradd,

Attach the following code to the DoubleClick event procedure:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FormB"

stLinkCriteria = "[VehID]=" & Me![YourVehIDControlInSubformA]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.

Sprinks
 
B

bradd

Thanks for the help, but it still doesn't work.

The Record Source for FormB is a table called "Vehicles". When I
DoubleClick on FormA, I go to FormB with no records - even if I put a
literal value in the "[VehID] = " parameter in FormA.

Any suggestions?
 
G

Guest

Bradd,

Try the following:

- Verify that the RecordSource of FormB is set to the table you think it is,
and that the table contains a field titled VehID, rather than VehicleID or
some other variation. If the RecordSource is set to the name of a stored
query, verify that the query includes the VehID field, and that it is spelled
identically to the reference in the code.

- Verify that you have changed the code string literals FormB, VehID, and
YourVehIDControlInSubformA to the name of your second form, the name of the
field in the RecordSource of the second form, and the name of the FormA
subform control that contains the data to match.

- Comment out the Openform call, and insert a MsgBox statement to verify
that the code is getting the correct value of VehID from your subform:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FormB"

stLinkCriteria = "[VehID]=" & Me![YourVehIDControlInSubformA]
MsgBox stLinkCriteria
'DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top