Help with Type Mismatch

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

Guest

I'll admit it, I will probably never get this right, I've tried, but I must
ask for help again...

stLinkCriteria = ("[FRName] = '" & Me.FRName & "'" AND "[DateOfService] >= &_
Me.StartDate & ")

I seem to recall that I needed to use the # symbol for dates, so I tried and
just made it worse, so if someone could help me out here, I would as always
appreciate it.

Cheers
 
Paul B. said:
I'll admit it, I will probably never get this right, I've tried, but
I must ask for help again...

stLinkCriteria = ("[FRName] = '" & Me.FRName & "'" AND
"[DateOfService] >= &_ Me.StartDate & ")

I seem to recall that I needed to use the # symbol for dates, so I
tried and just made it worse, so if someone could help me out here, I
would as always appreciate it.

Try this:

stLinkCriteria = _
"FRName = " & Chr(34) & Me.FRName & Chr(34) & _
" AND DateOfService >= " & _
Format(Me.StartDate, "\#mm/dd/yyyy\#")

I took the liberty of replacing the single-quotes you were using to
delimit Me.FRName with double-quotes -- Chr(34) -- just in case FRName
might ever contain a single-quote character or apostrophe.
 
Paul said:
I'll admit it, I will probably never get this right, I've tried, but I must
ask for help again...

stLinkCriteria = ("[FRName] = '" & Me.FRName & "'" AND "[DateOfService] >= &_
Me.StartDate & ")

I seem to recall that I needed to use the # symbol for dates, so I tried and
just made it worse, so if someone could help me out here, I would as always
appreciate it.


You were right about using a # sign around date/time values,
but the serious error is that the AND must be inside the
quotes:

stLinkCriteria = "[FRName] = '" & Me.FRName & " _
"' AND [DateOfService] >= #" & Me.StartDate & "#"

If you may be using your app on systems with other that USA
data formats, then the second line needs to be:

"' AND [DateOfService] >= #" & Format(Me.StartDate,
"m\d\yyyy") & "#"
 
Many thanks to both. Your continuous assistance to everyone here is greatly
appreciated.

Cheers
 
Back
Top