473,322 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Autopopulate Field

I've been searching and reading the forum, but with no success to find what I was looking for. I am trying to autopopulate a field in a form. I am not sure if I need to create a query or table to do this so please let me know how I would be able to perform this task. First, I have a table with field 1: units and field 2: has the corresponding battalions. I have a form that has the combo box for units and battalions. I want the battalion combo box to autopopulate the correct battalion based on what unit combo box is chosen. I hope I have been clear enough. Please let me know if I need to create a table or something else to do this. I don't know much about VB so if it could only be done in VB, please walk me through it. Thanks

Kim
Nov 24 '08 #1
3 1938
ChipR
1,287 Expert 1GB
The way I do this is to use the AfterUpdate event of the combo box to set the source for the other combo box. This is just for example:

private sub Combo1_AfterUpdate()
dim strSQL as String

if not (isnull(combo1)) then
strSQL = "SELECT Battalion FROM MyTable WHERE Units = """ _
& Combo1 & """"
combo2.RowSource = strSQL
end if
end sub

So your combo boxes have to have a Row Source Type of Table/Query. Also, I set the combo boxes to Limit To List and the Not In List event to:
Private Sub Combo1_NotInList(...)
Response = accDataErrContinue
end sub

That's just to supress the Access msg.
Nov 24 '08 #2
So how do I put these codes into vba? I open up vba, but i'm not sure how to input it.
Nov 24 '08 #3
ChipR
1,287 Expert 1GB
Go to your Combo Box properties, Event tab, click the AfterUpdate, click the elipsis, click Event Procedure. That will take you to the appropriate Form and Procedure in your editor.
Nov 24 '08 #4

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

Similar topics

2
by: Dave | last post by:
Hi folks, I'm in the middle of adding some validation functionality to an inventory tracking form. What I would like to do is have one dropdown menu/Listbox(Part Number) and another text...
3
by: Eric | last post by:
Hi, I'm just looking into the samples that are delivered withthe Enterprise Localization Framework/Toolkit. I have set it up and it all works fine. But.. now i have a question. I read a...
0
by: guy | last post by:
I am experimenting with the Enterprise Localization Toolkit. Using the Designer and Translator feature, I am able to include a new label in the Basic sample. Apparently, this can also be...
3
by: russr | last post by:
Hi, I need to autopopulate a second field based on the info that i have selected from a drop down box in the first field. I need to write both fields back to a SQL database... EXAMPLE: Field A...
4
by: PRLIT | last post by:
First, let me just say that I've been looking at this site for help for awhile now. Thank you for all the help you given me over the past few months. Second, I'm creating a form in Access 2007. I...
2
by: mvlt | last post by:
I would like to set-up an email data collection to gather volunteer hours from our volunteers. Is there a way to auto-populate a field if I use the HTML format. Each volunteer has a Contact ID, but...
6
by: GLEberts | last post by:
Hi, I would like to ask for some direction on what would be the best way to (1) Autopopulate a combo box to text boxes - used for a customer list (2) Then have the information saved in the...
2
by: debson | last post by:
Hi I have a main form in which I have linked subforms on tabs.. My problem is that I have one subform which is linked to a table which has 2 to 6 sessions in one table, we are required to fill out...
11
by: AccessBeetle | last post by:
I have custom login interface. When the user logs in I want to show something like "Welcome John Doe" on my switchboard form? How to do it? Hint please!! Also, when the user selects "Open data entry...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.