Results 1 to 3 of 3

Thread: Recordset is returning 0 - Desperate Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    1

    Cool

    I am trying to get back a recordset which contains a number
    My database looks roughly like this

    IdNum Name
    8 Sam
    9 John
    10 Sara

    I am getting back sam and john when they are selected but when
    it comes to sara, i am getting back a 0
    The same thing is happening for record no 20, 30 etc., infact anything
    with a trailing 0, I get back a 0
    The idnum field in the database is a long integer.
    I have tried defining my variable in vb as a long and it still does not work


    Public Sub Getidnumber(intidnum As Integer)

    Dim rsrecord As ADODB.Recordset


    Set rsrecord = New ADODB.Recordset
    rsrecord.Open "Select idnum, name from Table1", gCnn, adOpenDynamic, adLockOptimistic

    rsrecord.MoveFirst
    Do Until rsrecord.EOF


    'check for the exact match
    If rsrecord("name") = frmFirst.txtName.text Then
    intidnum = rsrecord("idnum")
    End If
    rsrecord.MoveNext
    Loop
    End If

    Please help. Thankssss

  2. #2
    Addicted Member
    Join Date
    Sep 2000
    Posts
    219
    Try this:

    Code:
            Set rsrecord = New ADODB.Recordset 
            rsrecord.Open "Select idnum, name from Table1", gCnn, adOpenDynamic, adLockOptimistic 
            With rsrecord
                   .MoveFirst
                   .Find "[name]='" & val(frmFirst.txtName.text ) & "'"
            End With

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Have you tried binding a control to the idnum and checking them that way?

    What do you get back for idnum 11?

    Very odd. More info please.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

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