If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > help please.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-25-02, 15:27
kinki_ngmy kinki_ngmy is offline
Registered User
 
Join Date: Mar 2002
Location: malaysia
Posts: 9
help please.

i have a form that contains ID(combobox), name(textbox),age(textbox)
these three fields is create under db1.mdb.
example:
ID=3000
Name=john
age=20
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
Reply With Quote
  #2 (permalink)  
Old 06-26-02, 14:11
jaydog96 jaydog96 is offline
Registered User
 
Join Date: Feb 2002
Location: North Carolina
Posts: 13
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,

j-Dog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On