Results 1 to 3 of 3

Thread: Access VB SQL... help!

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    34

    Exclamation

    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

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Question check your field data type

    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.

    Code:
    '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);")

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    34
    They are all text. Everything is text.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width