Dual Link Criteria in Button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that has a button where the user clicks and opens a from that
has two criteria: Name and date. The wizard works fine when using one, but
when I try to use both criteria, I get an error saying "Data Mismatch".
Here's the code:

stLinkCriteria = "[Analyst_Name]=" & "'" & Me![Analyst_Name] & "'" And
"[week_ending]=" & "#" & Me![Week_Ending] & "#"

any help would be appreciated.

Thanks in advance
 
Chris,

It's a syntax thing (I'm sure you knew that already...). Try:

stLinkCriteria = "[Analyst_Name]='" & Me![Analyst_Name] & "' And
[week_ending]=#" & Me![Week_Ending] & "#"

Watch out for wrapping in your newsreader, this is supposed to be in a
single line; or,

stLinkCriteria = "[Analyst_Name]='" & Me![Analyst_Name] _
& "' And [week_ending]=#" & Me![Week_Ending] & "#"

with a hard return after the underscore.

HTH,
Nikos
 
Hi Chris,

The quotes in
stLinkCriteria = "[Analyst_Name]=" & "'" & Me![Analyst_Name] & "'" And
"[week_ending]=" & "#" & Me![Week_Ending] & "#"
have gone astray. Try something like:

stLinkCriteria = "([Analyst_Name]='" & Me![Analyst_Name] & "')" _
& " AND ([week_ending]=#" & Me![Week_Ending] & "#);"

If you're using (or may use) non-US date formats, you'll need to modify
the date comparison to avoid ambiguity (e.g. is 12/05/05 12 May or 5
December).

I have a form that has a button where the user clicks and opens a from that
has two criteria: Name and date. The wizard works fine when using one, but
when I try to use both criteria, I get an error saying "Data Mismatch".
Here's the code:

stLinkCriteria = "[Analyst_Name]=" & "'" & Me![Analyst_Name] & "'" And
"[week_ending]=" & "#" & Me![Week_Ending] & "#"

any help would be appreciated.

Thanks in advance
 
John,

Thank you, I didn't thik to keep the AND inside the quotes.

--
Chris Freeman
IT Project Coordinator


John Nurick said:
Hi Chris,

The quotes in
stLinkCriteria = "[Analyst_Name]=" & "'" & Me![Analyst_Name] & "'" And
"[week_ending]=" & "#" & Me![Week_Ending] & "#"
have gone astray. Try something like:

stLinkCriteria = "([Analyst_Name]='" & Me![Analyst_Name] & "')" _
& " AND ([week_ending]=#" & Me![Week_Ending] & "#);"

If you're using (or may use) non-US date formats, you'll need to modify
the date comparison to avoid ambiguity (e.g. is 12/05/05 12 May or 5
December).

I have a form that has a button where the user clicks and opens a from that
has two criteria: Name and date. The wizard works fine when using one, but
when I try to use both criteria, I get an error saying "Data Mismatch".
Here's the code:

stLinkCriteria = "[Analyst_Name]=" & "'" & Me![Analyst_Name] & "'" And
"[week_ending]=" & "#" & Me![Week_Ending] & "#"

any help would be appreciated.

Thanks in advance
 
Back
Top