Results 1 to 3 of 3

Thread: Combo box and database

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    70

    Combo box and database

    Hi!
    I a problem which I would appreciate sime help on!

    what I am trying to do is select a name from a list and get my program to display the record in the database for the selected surname.

    what I Have at the moment is:

    Private Sub cmdFind_Click()
    Const Apos As String = "'"
    Dim Target As String


    Surname = InputBox("What is the Surname?")
    Target = "Surname = " & Apos & Surname & Apos
    Combo2.Clear
    datSponsor.Recordset.FindFirst Target

    Do Until datSponsor.Recordset.NoMatch
    Combo2.AddItem datSponsor.Recordset("Surname") datSponsor.Recordset.FindNext Target
    MsgBox ("Select Surname from Drop down List")
    Loop

    End Sub

    This works fine as it searches with just the surname using the following code:

    Private Sub cmdFind2_Click()

    Target = "Surname = " & "'" & Combo2.Text & "'"
    datSponsor.Recordset.FindFirst Target

    End Sub

    However the problem is when I use the code:

    Combo2.AddItem datSponsor.Recordset("Surname") & (" ") & datSponsor.Recordset("Forename")

    to display the surname and the forename in the combo box and don't have a clue when using two criteria i.e. surname, forename to dispaly the whole record!

    Could someone please help me out?

  2. #2
    Registered User
    Join Date
    Jun 1999
    Location
    palmdale, ca. USA
    Posts
    150

    sorry man...

    i'm still too new to vb to help you with that one.

    your problem "Combo box and database
    Hi!
    I a problem which I would appreciate sime help on!

    what I am trying to do is select a name from a list and get my program to display the record in the database for the selected surname."

    if you were doing it in ms access, i could tell you how.. basically a lookup .

    sorry about that.

    kevin

  3. #3
    Hyperactive Member wolfrose's Avatar
    Join Date
    Aug 2002
    Location
    Indiana
    Posts
    309
    I've always used queries to find things in a database, but you can try this:
    VB Code:
    1. Combo2.AddItem datSponsor.Recordset(0) & (" ") & datSponsor.Recordset(1)

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