How make a string not a string?

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

Guest

I know this must come up often, but I can't find the answer. The following
code produces a data type mismatch for the obvious reason in the Filter
argument: DonorID is something like "13456" and EndwID is like "F0016548." I
don't know how to strip the quotes. Is there a better variable type for this?

Dim DonorID, EndwID As String
With Forms!SwitchboardNew!DonorSubFrm
DonorID = !DonANDI
EndwID = !MchDonFNo
End With
Me.Filter = "MchDonANDI = DonorID" And "MchDonFNo = EndwID"
Me.FilterOn = True

Thanks in advance.
 
David Habercom wrote in message
I know this must come up often, but I can't find the answer. The following
code produces a data type mismatch for the obvious reason in the Filter
argument: DonorID is something like "13456" and EndwID is like "F0016548." I
don't know how to strip the quotes. Is there a better variable type for
this?

Dim DonorID, EndwID As String
With Forms!SwitchboardNew!DonorSubFrm
DonorID = !DonANDI
EndwID = !MchDonFNo
End With
Me.Filter = "MchDonANDI = DonorID" And "MchDonFNo = EndwID"
Me.FilterOn = True

Thanks in advance.

What are the datatypes of the fields? That is what determines whether
or
not one needs delimiters for the criteria. Here I'm assuming MchDonANDI
is numeric and MchDonFNo is text

Me.Filter="MchDonANDI=" & DonorID & " And MchDonFNo='" & EndwID & "'"

BTW, the declaration

Dim DonorID, EndwID As String

declares DonorID as variant, and EndwID as string. Use either

Dim DonorID as string, EndwID As String

or

Dim DonorID as string
Dim EndwID As String

if the intention is for both to be declared as strings.
 
Back
Top