472,789 Members | 1,131 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 software developers and data experts.

Auto populate a field based on selection from Combo box

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
4 13854
nico5038
3,080 Expert 2GB
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
whamo
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
3,080 Expert 2GB
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
whamo
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

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

Similar topics

3
by: sao | last post by:
I am currently using Access 2000. In my table it is the following fields that are set up: 1 - Staff Name 2 - Department This table is already populated with 100+ records (staff along with...
4
by: Sherwood Botsford | last post by:
Table Markers ID (Primary Key) This&That PointClass (Combo box) Points Table PointClasses PointClass (primary key) Points (number) Description (Text)
0
by: BK | last post by:
Hi, I have a problem. I need to auto populate fields based on a value entered in combo box. Initially, I put all the required fields in the combo box, and hide it (set to 0",0",0", ...), then...
1
by: Jim | last post by:
I have a new database in which I have a form where in one field I type a letter A, B, C or D and the field next to it autofills (auto lookups) with a description associated with the specific...
3
by: joseph.mccastlain | last post by:
Hello All, I am a new user to Access. I am currently designing a database consisting of four tables for multiple users. Rather than bore you with the goals and such, here is what I am...
5
FOE2272
by: FOE2272 | last post by:
I have tried every option that I can think of and most of them on this forum. The closest that I got was to bring up the field but it changed the other records based on what was chosen in one...
4
by: scolivas | last post by:
I think this is a me thing. but can't remember how to do it. I have a form that I am using and would like for a txt box to automatically populate based on what is selected in a combo box. here...
2
by: Ronald | last post by:
I hope somebody can help. I can't get into the specifics of my project, but I'll try to create a simple example: tblVehicle * VIN (text box) * Make (text box) * Model (text box) frmRepair
1
by: cluless | last post by:
Hey everybody, I have a database with one major form that has a few subforms and a listbox, and on the form there are buttons that link to other forms as well. Once the list box is clicked on, the...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.