Results 1 to 4 of 4

Thread: A little QueryDef Education Please?

  1. #1
    DonB
    Guest

    A little QueryDef Education Please?

    I am getting an error when I try to requery a table and I do not see anything wrong with the code. Can anyone assist?

    The error I get is:
    Run Time Error '3421'
    Data Type Conversion Error


    Here's the code:

    Public db As Database
    Public rs_detail As Recordset

    Private Sub Form_Load()
    ...
    ...
    Set rs_detail = db.OpenRecordset("SELECT * FROM items ORDER BY blk_no ", dbOpenDynaset, dbReadWrite)
    FindDetails (rs_master!blk_no)
    ...
    ...
    End Sub

    Private Sub FindDetails(findBlk As String)
    Dim qdef As QueryDef
    Dim strsql As String
    strsql = "SELECT * FROM items WHERE blk_no = " & findBlk & " ORDER BY blk_no "

    Set qdef = db.CreateQueryDef("", strsql)
    qdef.SQL = strsql

    ****** The error occurs on the next line *******
    rs_detail.Requery (qdef)



    Thanks for the help!
    DonB

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Location
    The Lone Star State
    Posts
    183
    strsql = "SELECT * FROM items WHERE blk_no = " & findBlk & " ORDER BY blk_no "

    Shouldn't this read

    strsql = "SELECT * FROM items WHERE blk_no = '" & findBlk & "' ORDER BY blk_no "

    with the single quotes for the findBlk variable?
    !

  3. #3
    DonB
    Guest
    I have never used single quotes around the variable and it hasn't presented a problem in the past. That being aside even if I do something simple like:

    strsql = "SELECT * FROM items"

    Set qdef = db.CreateQueryDef("", strsql)
    qdef.SQL = strsql

    ****** The "Data Type Conversion Error" error still occurs on the next line *******
    rs_detail.Requery (qdef)

    I have tried all types of combinations and no matter what I try I always get the same error

    DonB

  4. #4
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Have you tried using rs_detail.Requery (qdef.Name)?

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