Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double Filtering from a Subform 2

Status
Not open for further replies.

dedren

Technical User
Aug 14, 2006
43
US
I have a subform that I use to list some items. On that subform I made the OnClick property below:
Code:
DoCmd.OpenForm "frmSAR", , , "CaseNum= '" & CaseNum & "'" & " AND " & "ctlSARID = '" & txtSARID & "'"
It doesn't work though, and instead gives me a dialog box asking for txtSARID.

txtSARID is the name of the control on frmSAR.
ctlSARID is the name of the control on the subform.

I am trying to open frmSAR and have it open to the correct record.

The command filters fine if I only have:

Code:
DoCmd.OpenForm "frmSAR", , , "CaseNum= '" & CaseNum & "'"
 
What is supposed to be the value of txtSARID on the calling subform

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya dedren . . .

Try this:
Code:
[blue]   Dim Cri As String
   
   Cri = "[CaseNum]= '" & Me.CaseNum & "' AND [SARID] = '" & Me!ctlSARID & "'"
   DoCmd.OPenForm "frmSAR", , , Cri[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
PHV: txtSARID is a text field on the form that I am trying to open. It should be 'filtering' based on the value of a text field on the subform called ctlSARID.

Both of these fields refer to an autonumber field (SARID) in a table (tblSARlst).

TheAceMan1: I tried this code but I got the error message,
Code:
"Run-time error '3464':
Data type mismatch in criteria expression.
 
I'd try this:
Code:
DoCmd.OpenForm "frmSAR", , , "CaseNum='" & Me!CaseNum & "' AND SARID=" & Me!ctlSARID

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
GLaDOS approves! That works perfectly!! Thank you both for your help with this.

PHV: Might I ask why yours worked?
 
I should tell you that there are 12 people in this office that want to kiss your face for fixing this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top