By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 2,596 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

Auto populate a field based on selection from Combo box

P: 3
I have the need to populate a field based on the selection in a combo box.
Starting out simple. (2) tables tbl_OSE_Info and tbl_Input;
tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt
tbl_Input has three fields: OSE_Job, OSE_Name, OSE_Wt

I have populated tbl_OSE_Info table.
I need to create a form that will store the data in tbl_Input

I have racked my brain so much trying to figure out how to auto populate a field based on a combo box that I am now second guessing how I created the form.
I have created a form using the wizard.
"Choose the table or query where the object's data comes from:" tbl_Input
I added to the form:
Text field: OSE_Job
Combo Box: checked I want the combo box to look up the values in a table or query. Next>
Selected Table: tbl_OSE_Info, Next>
Selected All Available fields (Key, OSE_Name, OSE_Wt) Next>
Selected Hide key column (recommended) Next>
Selected Store that value in this field: OSE_Name
Labled the combo box OSE_Name.
Properties for Combo Box: cbo_OSE_Name
Name: cbo_OSE_Name
Control Source: OSE_Name
Row Type: Table/Query
Row Source: Select........
Column Count: 3
Column Heads: No
Column Widths: 0";1",1"
Bound Columns: 1

Added the Text field OSE_Wt to the form.
Saved the form as frm_Data

I need to populate the OSE_Wt field on the form base on a selection made in the combo box and have all the data stored in the tbl_Input form.

Please help before the rest of my hair falls out.
Oct 12 '07 #1
Share this Question
Share on Google+
4 Replies


nico5038
Expert 2.5K+
P: 3,072
You can use the Combo's AfterUpdate event to move the values selected in the combo into the fields on your form. (I assume the form is based on the Target table!)
The general needed move for the first combofield is:
Me!fieldname = Me!Comboname.Column(0)
for the second combofield use:
Me!fieldname = Me!Comboname.Column(1)
The columns are so-called "zero based".
After the moves issue a:
Me.Refresh
This will force the new data to become visible.

Getting the idea ?

Nic;o)
Oct 12 '07 #2

P: 3
You can use the Combo's AfterUpdate event to move the values selected in the combo into the fields on your form. (I assume the form is based on the Target table!)
The general needed move for the first combofield is:
Me!fieldname = Me!Comboname.Column(0)
for the second combofield use:
Me!fieldname = Me!Comboname.Column(1)
The columns are so-called "zero based".
After the moves issue a:
Me.Refresh
This will force the new data to become visible.

Getting the idea ?

Nic;o)
I receive this error:
Microsoft Access can't find the macro 'Me!OSE_Wt=Me!OSE_Name.'
The macro (or its macro group) doesn't exist, or the macro is new but hasn't been saved.
Note that when you enter the macrogroupname.macroname syntax in an argument, you must specify the name the macro's macro group was last saved under.
I have never used the 'Me' part so I am unsure what the error is telling me.
This is some of the information in my combo box:
Name: OSE_Name
Control Source: OSE Name
Row Source: SELECT [tbl_OSE].[Key], [tbl_OSE].[OSE_Name], [tbl_OSE].[OSE_Wt] FROM tbl_OSE;
After Update: Me!OSE_Wt=Me!OSE_Name.Column(2)
Me!Refresh

Further assistance would be appreciated.
Oct 12 '07 #3

nico5038
Expert 2.5K+
P: 3,072
You'll have to remove the statement from the textbox behind the afterupdate event first.
When the textbox is empty, double-click the AfterUpdate label.
Now the textbox will hold something like "Procedure" and there will be a [...] button at the end of the line when you single-click on the "Procedure".
After pressing the [..] button the VBA editor will open and the cursor will be at the position where you need to place the statements I gave.
Close the code (top right [X] button) and save the form. Then try again.

Nic;o)
Oct 12 '07 #4

P: 3
You'll have to remove the statement from the textbox behind the afterupdate event first.
When the textbox is empty, double-click the AfterUpdate label.
Now the textbox will hold something like "Procedure" and there will be a [...] button at the end of the line when you single-click on the "Procedure".
After pressing the [..] button the VBA editor will open and the cursor will be at the position where you need to place the statements I gave.
Close the code (top right [X] button) and save the form. Then try again.

Nic;o)
AWSOME!!!!!! THANK YOU!!!!! THANK YOU!!!! THANK YOU!!!!!!!
Oct 12 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.