Results 1 to 2 of 2

Thread: help please.

  1. #1
    Join Date
    Mar 2002

    Unanswered: help please.

    i have a form that contains ID(combobox), name(textbox),age(textbox)
    these three fields is create under db1.mdb.
    once the user select the ID from the combo box(select 3000), when the user release the mouse, the textbox of name will automatically appear
    "John", how to do this? any code is appreciate.
    p/s: this form is run under visaul basic

  2. #2
    Join Date
    Feb 2002
    North Carolina
    First, a word of advice: if possible, avoid using "name" as a field name in Access. Since it is a property of most objects in the database, it can cause conficts when setting up reports and in VBA code.

    Having said that, what you need can be accomplished using the AfterUpdate event of your combobox. In the design view of the form, select the combo box and open up the properties box. Go to the Events tab and look for the AfterUpdate event. In the box for the AfterUpdate event, type a left square bracket ( "[" - next to the P key) and words "Event Procedure" will appear. Click the ellipsis (...) to the right of the box to open up the VBA editor. A procedure for the AfterUpdate event will be started for you.

    In order to automatically update the textbox for name, use the following code (substitute your actual form control names):

    Me.<yourtextboxname> = DLookup("name", "<yourtablename>", "ID = " & <yourcomboboxname>)

    Look up the AfterUpdate event and the DLookup function in the Helpfile for some examples.

    Hope it helps,


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts