sql string to recordset

spinkung

Registered User.
Local time
Today, 14:41
Joined
Dec 4, 2006
Messages
267
Hi all,

I'm trying to get a SQL quesry into a recordset but i keep getting an error message saying: type mismatch


here's what i've got......
Code:
Dim sql As String
Dim rs As Recordset

sql = "SELECT multiFlag " & _
      "FROM Charges " & _
      "WHERE code = '" & Me.comboCharge.Column(0) & "'"
      
Set rs = CurrentDb.OpenRecordset(sql)

can anyone help?

Thanks,
Spinkung
 
you have single quotes around the value from the combo box, this signifies the field is text. If the field
Code:
 is numeric then the single quote should be removed.
 
thanks for the reply...


no, my field is a 5 char string so the single quotes should be ok??
 
The error message sugests that the field called code is not text type. What happens if you remove the the single quotes?
 
when i remove the single quotes i get a : 'too few paramteters, expected 1',
error message??

when i break the code and hover over the 'me.comboCharge.column(0)' value i get the right result which is @DEL01 (@DEL02, 03 etc depending on the selection)??
 
Is Code a field in table Charges or what? If so how is it defined. The more info you give us the more likely you are to get a solution quickly.
 
'code' is a field in the table 'charges'.
The combo box value (comboCharge.column(0)), i'm using in my sql string has its row source linked to the table 'charges'.
The field is a text type 6 long.
MultiFlag, which is the result im trying to get into my recordset, is a YES/NO field.
 
Can you post a copy of your database on here? Then we can have a look at it.
 

Users who are viewing this thread

Back
Top Bottom