Problem with setting condition for 2nd form

ds_8805

Registered User.
Local time
Today, 04:07
Joined
Jan 21, 2010
Messages
70
Hello Everyone. I am having a small problem. I want to open a second form from the first form based on a criteria.

stLinkCriteria = "[PayeeName]=" & "'" & Me![PayeeName] & "'" And "[PayeeID]=" & Me![PayeeID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


initally when I just set the criteria as payeename, it was working perfectly fine. However, when I set payeeID also as part of the criteria, I am getting a type mismatch error. PayeeID is an autonumber type. Hope someone can help me figure out what the mistake is.

Thanks :)
 
I think

Code:
stLinkCriteria = "[PayeeName]=" & "'" & Me![PayeeName] & "'" And "[PayeeID]=" & Me![PayeeID] & "'"
needs to be

Code:
stLinkCriteria = "[PayeeName]=" & "'" & Me![PayeeName] & "'" And "[PayeeID]=" & Me![PayeeID]
dropping the final

& "'"
 
hey i tried it but error still persists. I still get type mismatch error!
 
Maybe:

Code:
stLinkCriteria = "[PayeeName]=" & "'" & Me.PayeeName & "'" And "[PayeeID]=" & Me.PayeeID
 
Hey thanks for ur help . will try this :D thks!
 
Hey the problem still exists. This is rather weird. I think I have tried almost everything. I think I will just try to set the condition using query. Thanks so much for ur help :D
 
Noticed something as well. Try this:

Code:
stLinkCriteria = "[PayeeName]='" & Me.PayeeName & "' And [PayeeID]=" & Me.PayeeID
 
hey works perfectly fine! Thanks alot. But may I ask u y dun we need to put the "'" cos in my previous ones i wrote that. Thats y i followed the same thing. Sorry I m still kindof new n trying to get used to all this.
 
You can if you wanted to, but it's just unecessary and harder to read. However, if you were going to use yours you must open/close the string correctly. So using your original post:

Code:
stLinkCriteria = "[PayeeName]=" & "'" & Me![PayeeName] & "'" [COLOR=Red]& " [/COLOR]And [PayeeID]=" & Me![PayeeID]

The And was outside the string so the compiler thought it was a variable.
 
ooohh thanks thanks for ur help soo much! Really appreciate it! :)
 

Users who are viewing this thread

Back
Top Bottom