PDA

Click to See Complete Forum and Search --> : Access VB SQL... help!


damarious
Sep 12th, 2000, 04:33 PM
The code I have below (comments stripped) throws a type mismatch error at the line specified.... any ideas?

Dim rst As Recordset
Dim dbs As Database
Dim strSQL1 As String
Dim strIP As String
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("SELECT ips FROM MainData WHERE (MainData.cnum = '123456');") <- THROWS ERROR!

rst.MoveFirst
strIPS = rst![ips]
rst.Close
Set dbs = Nothing
MsgBox strIPS

DrewDog_21
Sep 12th, 2000, 05:20 PM
What is the data type of the field MainData.cnum? The name
implies a numeric type, and you pass it a numeric value in
your SQL statement. But you have the number in single
quotes, and quotes are only for string values.


'you have this
Set rst = dbs.OpenRecordset("SELECT ips FROM MainData WHERE (MainData.cnum = '123456');")

'if MainData.cnum is a numeric field - single, double,
integer, etc. then you should have this
Set rst = dbs.OpenRecordset("SELECT ips FROM MainData WHERE (MainData.cnum = 123456);")

damarious
Sep 12th, 2000, 05:34 PM
They are all text. Everything is text.....