Results 1 to 6 of 6

Thread: need help to retrieve data

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    Penang, Malaysia
    Posts
    51

    Question

    i have 2 textbox (Customer Code, Customer Name) which if i key in the customer code in first textbox, the program will display the customer name on 2nd textbox automatically (where the customer data store in database using ODBC). What should i do so that this method can executed without using any command button.

    TQ.
    CK

  2. #2
    Lively Member
    Join Date
    Jun 2000
    Location
    A caravan park in the Midlands (UK)
    Posts
    101

    Question

    You could always use the dastardly 'lost focus' event. When user leaves the text control search your database (or recordset if you already have the data) for the appropriate customer name (and vice-versa).

    If u'r not adding customers I'd get the data into two combo boxes. If allowing key presses search combo for next match and point search the recordset for appropriate name to go in the name combo. More work but it's neater and you don't need the 'lost focus' then.
    Anakim

    It's a small world but I wouldn't like to paint it.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    Penang, Malaysia
    Posts
    51
    If i want to use 'lost focus' control, what code should i put between the command?

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Exclamation

    Hi leeckeat,

    Just cut your present code from the command button and paste it into the Lost_Focus event of the textbox. It's as simple as that.

    All the best.

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    Penang, Malaysia
    Posts
    51

    Exclamation wrong coding?

    i using if...then..else statement but when i run the program, it "hang" there. I need to press ctrl+break to stop the program.

    code:

    Set rstTemp = Db.OpenRecordset("select * from Customer", dbOpenDynaset)

    Do While Not rstTemp.EOF
    If rstTemp.Fields(0) = Text1.Text Then
    rstTemp.Fields(1) = Text2.Text
    End If
    rstTemp.MoveNext
    Loop
    rstTemp.Close

  6. #6
    Member
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    32
    hi leeckeat.... you're displaying it on a textbox rite???
    instead of rstTemp.Fields(1)=Text2.text, isn't it supposed to be Text2.Text=rstTemp.Fields(1).....

    Code:

    Set rstTemp = Db.OpenRecordset("select * from Customer", dbOpenDynaset)

    Do While Not rstTemp.EOF
    If rstTemp.Fields(0) = Text1.Text Then
    Text2.Text=rstTemp.Fields(1)
    End If
    rstTemp.MoveNext
    Loop

    rstTemp.Close

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