473,320 Members | 2,004 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,320 software developers and data experts.

Combo box in form not updating as expected

Hello all

I am trying to create a (simple) database that will hold an inventory of my things, using two tables. One will hold the objects and the other, which object is contained in which.

The objects table will hold information of their name (text value) as well as info whether an object is a container itself or just a normal object (a boolean value). Objects are supposed to be unique and should only be contained in one container (which in turn can be contained in another container etc.). No object can be contained in two containers at the same time.

The contained objects table has records of two values, one for the object that is contained and one for the container. Those IDs are numerical values and are related to the autonumber values used as a primary key in the first table.

In order to add records to the second table I have created a form that uses two combo boxes to select the object to be contained, and the container. For populating those combo boxes I use two separate queries. The first returns only the objects that are not already stored in the second table (remember that I need to put an object only to one container at a time, so if the object is already contained it shouldn't appear on the list). The second returns only those objects that are marked as containers (you can put objects only in containers).

I believe the structure to be quite simple and sufficient in order to do what I need. However, I am experiencing two problems:
1. When I am in the form for adding objects in containers, the first time that I open the form, the combo box for the objects (the first one), shows only the objects that are not contained in the second table (as expected). However, if I add a new object in the second table and go to the next record, although I have used the requery macro in the AfterUpdate field of the combo box, I still get all the objects that were displayed just after opening the form. If I close the form and reopen it, the combo box contains the correct objects (only those not contained). You understand it isn't practical to close and reopen forms just to make it work properly.

2. When I reopen the form and go to the records already in the table, I can see the container that I have selected for an object in the second combo box but the first combo box is empty! However, if I open the table itself, the values are there and are correct!

I may be doing something really silly but I can't get it to work properly. The queries have been created using the wizard in MS Access (and not by writing SQL myself). I have attached a zip file containing the database since I believe it would be much easier to take a look rather than trying to describe exactly how the queries were formed. If you have any suggestions as to what am I doing wrong or need more info, please ask.

The database was create in MS Access 2010. The form is bound to the tables of the database.

Thanks in advance
George
Attached Files
File Type: zip Database3.zip (54.9 KB, 105 views)
Apr 19 '13 #1

✓ answered by Seth Schrock

Sorry, I can't open attachments while at work and I don't even from home when I don't know the person. I can, however, try to help you as I believe that I have a pretty good idea of what is going on.

In answer to your first question... The reason that the record doesn't get removed from the combo box is that all the records are gathered when the form is first opened, which is why it works to close and reopen the form. What you need is a requery, but not the combo box's AfterUpdate event but in the form's AfterUpdate event. The reason being that the record hasn't saved to the table until the form's AfterUpdate event. At the time of the control's AfterUpdate event, a requery won't have new data in the table. Give it a try and see what happens.

I also know what is happening in your second question, but per site rules, only one question is allowed per thread. If you could post your second question in a new thread, I would be glad to help you out.

2 5641
Seth Schrock
2,965 Expert 2GB
Sorry, I can't open attachments while at work and I don't even from home when I don't know the person. I can, however, try to help you as I believe that I have a pretty good idea of what is going on.

In answer to your first question... The reason that the record doesn't get removed from the combo box is that all the records are gathered when the form is first opened, which is why it works to close and reopen the form. What you need is a requery, but not the combo box's AfterUpdate event but in the form's AfterUpdate event. The reason being that the record hasn't saved to the table until the form's AfterUpdate event. At the time of the control's AfterUpdate event, a requery won't have new data in the table. Give it a try and see what happens.

I also know what is happening in your second question, but per site rules, only one question is allowed per thread. If you could post your second question in a new thread, I would be glad to help you out.
Apr 19 '13 #2
@Seth Schrock
Dear me ...
1. I thought I read the rules completely before posting that
2. Your suggestion worked perfectly, thanks for that. I will be posting another thread. Thanks a million

George
Apr 19 '13 #3

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

Similar topics

5
by: Xenophobe | last post by:
I would like to use the same form for adding new records and editing existing records. New form values are contained in $_POST. Database values are contained in an associated array. It seems to me...
2
by: Raphael Gluck | last post by:
Hi everyone I am trying to create a form to update a database table. I have all the fields, set up, and a submit button happily processes my form. However, I am trying to create a field in my...
1
by: Jason Wood | last post by:
Hi everyone, I've a simple table containing member details. I've written a SELECT to select all the members. I've based the form on this select, using the from wizard. Once built I've...
10
by: motessa | last post by:
Hello All, I am new to Access and have been looking for answers to my problem on the internet and have not found it yet. I hope someone can give me a hint. Thanks so much. I have a form...
1
by: Martin Racette | last post by:
Hi, I tried the first part of the suggested code below (in a test program first), and all I get is an error telling me that "System.Windows.Forms.ToolStripStatusLabel" is not define and the same...
4
by: Thomadh | last post by:
I have only updated 1 table with a Form to date Can you update more than 1 table from a single Form input? The Wizard seems to allow only 1 Table to be selected as the data source If so any quick...
8
by: JReneau35 | last post by:
I am a novice to MS Access. I have about 10 to 15 tables that link to a single form. I use unique ID's to link all of these tables together. Since the ID for the customer never changes, I was...
4
by: Duvik | last post by:
Hi, Would you know how to keep a form active? I am proccessing an image and the proccess is indicated by a progress bar. But after about 2 seconds the whole form becomes inactive and the progress...
0
by: jimmarq | last post by:
I have a form with textboxes that are databound to objects named "Person." When the user enters the form for the first time, if there is no object in the binding list, an object is created and...
3
by: Kernel Kev | last post by:
Hi, im doing a college assignment using Access and i seem to have hit a hard rock thats getting in my way. I will explain my task solution in hope you may be able to explain the best way to do this:...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.