need help how can i retrieve db query records in vb6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kato martin
    New Member
    • Oct 2007
    • 3

    need help how can i retrieve db query records in vb6

    hi, i have designed an access database query with sums and expressions. however i have failed to retrieve any recordsets from this db query in vb6.... below i the code im currently using..but each time i try, i get a message " data type mismatch in criteria expression"

    [CODE=vb]Dim Db As Database
    Dim RsM As Recordset
    Dim rsS As Recordset
    Dim dT As Date

    Private Sub txtsite_Change( )
    Set Db = oDB

    Dim strSQL As String
    Dim sNa As String

    sNa = txtsite
    strSQL = "SELECT wkno,wkno from qpdtn WHERE wkno LIKE '" & txtsite & "*' or wkno LIKE '" & txtsite & "*' ORDER BY wkno"
    'MsgBox Str
    Set Rs = Db.OpenRecordse t(strSQL)
    lst.Clear
    lst1.Clear

    Do While Not Rs.EOF
    lst.AddItem (Rs(0))
    lst1.AddItem (Rs(1) & "")

    Rs.MoveNext
    Loop
    If lst.ListCount > 0 Then

    setGrid1

    End If

    End Sub
    Private Sub setGrid1()
    datexptk.Record Source = "SELECT wkno,sumofmonda y,sumoftuesday, totalsums FROM qpdtn WHERE wkno='" & lst.List(0) & "'"
    datexptk.Refres h

    End Sub
    Private Function oDB() As Database
    Set oDB = OpenDatabase("c :\dihe\db4.mdb" )

    End Function[/CODE]
    Last edited by debasisdas; Oct 15 '07, 05:38 AM. Reason: Formatted using code tags.
  • epots9
    Recognized Expert Top Contributor
    • May 2007
    • 1352

    #2
    Moved to the VB Forums where the resident experts can better assist you.

    **moved from Programming Challenges.

    Comment

    • chandru8
      New Member
      • Sep 2007
      • 145

      #3
      hi marti,
      Are you coding this in database vb form mean you have to use
      set db = current database()

      Comment

      • kato martin
        New Member
        • Oct 2007
        • 3

        #4
        Originally posted by chandru8
        hi marti,
        Are you coding this in database vb form mean you have to use
        set db = current database()
        hi chandru, big thanx 4 yo concern.. yeah i have to use set db = current database() or else i'l just keep on getting more errors..also my database is in 97 format. i think the trouble is in defining the values in the fields i am trying to select from. thanx again..ol the best.

        Comment

        Working...