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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I open another form based on multiple criteria? 1

Status
Not open for further replies.

tcolan

Technical User
Apr 28, 2003
49
US
Hi,

I am creating a button that needs to open another form. Going through the wizard, I am only able to set the criteria for one field to match, except I want to use 2 fields to designate the filter that needs to be placed on the opening of the new form.

I know that I need to do something to the stLinkCriteria VBA code but it's not working quite right. I have added an And statement to the original criteria, but it does not seem to take.

Thanks for your help,
Tom

Private Sub Command29_Click()
On Error GoTo Err_Command29_Click

Dim stDocName As String
Dim stLinkCriteria As String


stDocName = "44-1 frm_Script_Detail_ from_45"

stLinkCriteria = "[Test Script ID]=" & "'" & Me![Test Script ID] & "'" And [Test Case ID] = Me![Test Case ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command29_Click:
Exit Sub

Err_Command29_Click:
MsgBox Err.Description
Resume Exit_Command29_Click

End Sub
 
Nearly there, just concatinate the string. For testing purposes you might want to do a msgbox stLinkCriteria to see if it is concatinated correctly before applying it:

[tt] stLinkCriteria = "[Test Script ID]='" & Me![Test Script ID] & "' And [Test Case ID] = " & Me![Test Case ID][/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top