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

Working with Criteria in Forms ?

Status
Not open for further replies.

maverick

MIS
Apr 21, 1999
193
US
Hey Guys & Gals,<br><br>I have a button on a form, that I would like to click to open another form, but I want to filter the records by two fields on the previous form.<br><br>I typed in this to get one filter;<br>DoCmd.OpenForm &quot;New Form&quot;,,, &quot;[Field on Previous Form]='Criteria1'&quot;<br>DoCmd.Close acForm, &quot;Previous Form&quot;<br><br>But how do I get it to use the criteria (Value) that's in the field on the &quot;Previous Form&quot; and use two Fields to filter with .?.?<br><br>Thanks in Advance !!!<br><br>
 
Simply add the parameters together with the word &quot;AND&quot;<br>---------------------------------------<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim stDocName As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim stLinkCriteria As String<br><br>&nbsp;&nbsp;&nbsp;&nbsp;stDocName = &quot;Second Form&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;stLinkCriteria = &quot;[FirstName]=&quot; & &quot;'&quot; & Me![FirstName] & &quot;' AND [LastName] = '&quot; & Me![LastName] & &quot;'&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenForm stDocName, , , stLinkCriteria<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.Close acForm, &quot;First Form&quot;<br>----------------------------------------<br><br>&nbsp;&nbsp;just tested this code and it works<br>Use the Wizard to create a Form Open button and choose &quot;Open form and specify data to it&quot;.<br>&nbsp;&nbsp;&nbsp;&nbsp;<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Thanks Bro..<br><br>I was tring variations of AND OR,<br>But I see I was putting the AND in the wrong place..<br><br>Thanks Again DougP, Your Bad ! a good bad...
 
Hey Doug,<br><br>I may still be doing something wrong..<br><br>I'm getting an error; Type mismatch<br><br>What does that mean?<br><br>Thanx..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top