Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Combo Box
Colin Smyth 
      
2 years ago
This may have been discussed before but I can't find it. I have a table with Towns in one field and Postcodes in the other. How can I set up a combo box on my form, so that I type in the town in one field and postcode is then automatically added to the postcode field. Thank you.
Adam Schwanz  @Reply  
           
2 years ago
AfterUpdate & DLookup

Just set the value in the after update event of your town field. Could be something like
Postcode = DLOOKUP("Postcode","MyTable","Town=""" & TownField & """")

Or you could store the post codes inside of the combo box as well, and use the .Column(#) property, then do Postcode = TownField.Column(#) kind of thing, but the dlookup should be fine.
John Davy  @Reply  
         
2 years ago
Hi Colin

Just remember that you will have the same zipcode in multiple towns and some towns have multiple zip codes.

John
Richard Rost  @Reply  
          
2 years ago
Better to go the other way... type in the postcode and have it look up the city/state.

ZIP Code Lookup
Colin Smyth OP  @Reply  
      
2 years ago
Thank you everyone.
My problem, Richard is that some people don't know their Postcode (Zip), so for me it would be easier to use the town (I don't need state or country). I tried changing your initial statement of  ID= Nz(dlookup statement but got confused with the double double quotes because Town name is obviously a string rather than an integer. The rest of your code I could follow - could you please assist me. I watched your double double quotes video again but still not getting it correct. Thanks
Kevin Robertson  @Reply  
           
2 years ago
Adam gave you the correct use of double double quotes in his comment above.

If you still can't get it to work please post what you have so we can see it and correct where necessary.
Colin Smyth OP  @Reply  
      
2 years ago
Thank you all for your help. One other question. I have set up a form which enables me to add a new town and postcode to the table if that town does not exist. This works fine and the town and postcode show straightaway in the table. However, it doesn't show on the form until I close the form and reopen it. I have tried doing a requery on the both the input form and also on the main form but that doesn't seem to work either. Any suggestions on what to do please?
Kevin Robertson  @Reply  
           
2 years ago
Have you tried to requery the Combo Box directly?

    ComboBoxName.Requery
Colin Smyth OP  @Reply  
      
2 years ago
Hi Kevin. Thank you - where in the properties are you suggesting I put the above. I tried in afterupdate but that didn't work. If I click refresh all on the menu bar above, it works instantly but I need it to do it automatically but maybe I am not putting it in the right propery of the form.
Kevin Robertson  @Reply  
           
2 years ago
I would do it in the Close event of the Input Form. I like to check that the Form I am referencing is open so I don't receive an error if it's not.

    If CurrentProject.AllForms("MainFormName").IsLoaded Then
        Forms!MainFormName!ComboBoxName.Requery
    End If


Replace MainFormName with the actual name of your Form.

Is Form Loaded
Value From a Form
Colin Smyth OP  @Reply  
      
2 years ago
Thank you Kevin. Problem solved. Really appreciate your help
Kevin Robertson  @Reply  
           
2 years ago
You're welcome.
Colin Smyth OP  @Reply  
      
2 years ago

Colin Smyth OP  @Reply  
      
2 years ago
One last question. If I try to type in a name in the Town field (which is a combobox = based on a table) and if the town is not in the table I get the above error message. Once I put in a name in the field that is in the towns table, then I click on the tab in red which opens a form that allows me to add the new name to the table. Is there a way, I can not get the message and go straight to the form to add the new name.
Kevin Robertson  @Reply  
           
2 years ago
Kevin Robertson  @Reply  
           
2 years ago
Colin Smyth OP  @Reply  
      
2 years ago
Thanks Kevin, the list items edit forms solved my problems. Much appreciated

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/17/2026 5:12:02 AM. PLT: 1s