Type Mismatch

E

Emma Aumack

Can someone tell me how to get this to work.

I have a subform that has an account_no field. When this field is double
clicked another form pop up and is filtered on the account_No.

But I want to do another filter on the records in the popup form based on a
field on the main form. How do I do this? I can get the first part to work
but I can't figure out how to get then 2nd part to work.

This is the code I have so far:

Private Sub cbo_LOCAct_AccountNo_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria1 As String
Dim stLinkCriteria2 As String

stDocName = "Frm_LUComplianceHistory"
stLinkCriteria1 = "[txt_Account_Number] =" & Me![cbo_LOCAct_AccountNo]
stLinkCriteria2 = "[txt_Product] =" & Me.Parent![txt_GrpProdCat]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria1 And
stLinkCriteria2, acFormReadOnly
End Sub

I keep getting a Type mismatch on the Docmd.Openform line. And I suspect it
has to do with the StLinkCriteria but I can't figure out how to get both sets
of criteria in my code.

Please help!!!
 
S

Stuart McCall

Emma Aumack said:
Can someone tell me how to get this to work.

I have a subform that has an account_no field. When this field is double
clicked another form pop up and is filtered on the account_No.

But I want to do another filter on the records in the popup form based on
a
field on the main form. How do I do this? I can get the first part to
work
but I can't figure out how to get then 2nd part to work.

This is the code I have so far:

Private Sub cbo_LOCAct_AccountNo_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria1 As String
Dim stLinkCriteria2 As String

stDocName = "Frm_LUComplianceHistory"
stLinkCriteria1 = "[txt_Account_Number] =" & Me![cbo_LOCAct_AccountNo]
stLinkCriteria2 = "[txt_Product] =" & Me.Parent![txt_GrpProdCat]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria1 And
stLinkCriteria2, acFormReadOnly
End Sub

I keep getting a Type mismatch on the Docmd.Openform line. And I suspect
it
has to do with the StLinkCriteria but I can't figure out how to get both
sets
of criteria in my code.

Please help!!!

The 'And' keyword must be embedded in the criteria string. Change the DoCmd
line to:

DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria1 & " And " &
stLinkCriteria2, acFormReadOnly

(watch out for word wrap - that is one line of code)
 
E

Emma Aumack

Thank you Stuart!

I'm getting there. However, now when I double click on the LOCAct_AccountNo
field, an "Enter Parameter Value" dialog box appears with the text that is in
the txt_GrpProdCat. If I type in the product group, i.e., Grafts, then
Frm_LUComplianceHistory pops up with the correct records in it. How do I
keep from getting the dialog box from appearing? The code should be getting
that parameter from txt_GrpProdCat.
--
www.bardpv.com
Tempe, Arizona


Stuart McCall said:
Emma Aumack said:
Can someone tell me how to get this to work.

I have a subform that has an account_no field. When this field is double
clicked another form pop up and is filtered on the account_No.

But I want to do another filter on the records in the popup form based on
a
field on the main form. How do I do this? I can get the first part to
work
but I can't figure out how to get then 2nd part to work.

This is the code I have so far:

Private Sub cbo_LOCAct_AccountNo_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria1 As String
Dim stLinkCriteria2 As String

stDocName = "Frm_LUComplianceHistory"
stLinkCriteria1 = "[txt_Account_Number] =" & Me![cbo_LOCAct_AccountNo]
stLinkCriteria2 = "[txt_Product] =" & Me.Parent![txt_GrpProdCat]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria1 And
stLinkCriteria2, acFormReadOnly
End Sub

I keep getting a Type mismatch on the Docmd.Openform line. And I suspect
it
has to do with the StLinkCriteria but I can't figure out how to get both
sets
of criteria in my code.

Please help!!!

The 'And' keyword must be embedded in the criteria string. Change the DoCmd
line to:

DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria1 & " And " &
stLinkCriteria2, acFormReadOnly

(watch out for word wrap - that is one line of code)
 

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