Results 1 to 6 of 6

Thread: VB6 Halp required

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2009
    Posts
    2

    Post VB6 Halp required

    Hey guys im designing a system to search a MS Access database and I just cant seem to get it working.

    Dim key As String, str As String
    Dim count, a As Integer
    count = frmAdmin.Adodc1.Recordset.RecordCount
    key = " "
    key = InputBox("Enter the policy No whose details u want to know: ")
    'For a = 1 To count
    'If key = frmAdmin.Adodc1.Recordset.Fields(0) Then
    'Call MsgBox("Client Exists", vbOKOnly + vbInformation, "Client Exists")
    'Else
    'Call MsgBox("client does not exist", vbOKOnly + vbInformation, "Client does not exist")
    ' End If
    'Next a


    'str = "select * from Client where [Policy Number]=" & key
    'frmAdmin.Adodc1.Recordset.Open str
    'frmAdmin.Adodc1.Recordset.Close
    While Not (frmAdmin.Adodc1.Recordset.EOF) And found = False
    If frmAdmin.Adodc1.Recordset.Fields(0) = key Then
    Call MsgBox("record exists", vbOKOnly + vbInformation, "Record found")
    found = True
    Else
    Call MsgBox("record does not exist", vbOKOnly + vbInformation, "record not found")
    End If
    frmAdmin.Adodc1.Recordset.MoveNext
    Wend

    thats the code Im currently using. as you can see Im using ADODC and I even tried using SQL to no avail...Please assist....

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: VB6 Halp required

    Welcome to VBForums.com

    Will this help you...???
    Code:
          'set up the recordset, and load the data:
          Dim rs As ADODB.Recordset
            Set rs = New ADODB.Recordset
    
            rs.Open "SELECT Client where Policy_Number= '" & strKey & "'", cn, adOpenStatic, adLockReadOnly, adCmdText
    
            If rs.EOF Then
              MsgBox "No data found!"
            Else
    
                  '..do what we want with the data in this record
                MsgBox rs.Fields("field1").Value
    
            End If
          'tidy up
            rs.Close
            Set rs = Nothing
    Also, view this thread:
    http://www.vbforums.com/showthread.php?t=416218

    Good luck..

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2009
    Posts
    2

    Re: VB6 Halp required

    Dim key As String, str As String
    Dim count, a As Integer
    count = frmAdmin.Adodc1.Recordset.RecordCount
    key = " "
    key = InputBox("Enter the policy No whose details u want to know: ")
    'set up the recordset, and load the data:
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset

    rs.Open "SELECT Client where Policy_Number= '" & key & "'", adOpenStatic, adLockReadOnly, adCmdText

    If rs.EOF Then
    MsgBox "No data found!"
    Else

    '..do what we want with the data in this record
    MsgBox rs.Fields("field1").Value

    End If
    'tidy up
    rs.Close
    Set rs = Nothing


    End Sub

    the error im getting is Run time error 3001: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

    HELP....

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: VB6 Halp required

    You have to include the connection also...
    Code:
    Dim cn As ADODB.Connection
    Set cn = New ADODB.Connection
        cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
          "Data Source= " & App.Path & "\abc.mdb"
        cn.Open
    Make sure, you had added reference to Microsoft ActiveX Data Objects

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  5. #5
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: VB6 Halp required

    First of all, go through our Database FAQ section to learn about ADO

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: VB6 Halp required

    Thread moved to 'Database Development' forum (the 'VB6' forum is only meant for questions which don't fit in more specific forums)

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