473,395 Members | 1,823 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,395 software developers and data experts.

Combo Box Requery Not Working

waynetheengineer
Hi,

I have a combo box on a form with a list of cities in it based on a single field city table. I also have a command button on this form that opens up another form that allows the user to enter in new cities to the city table. Now, after i dd new cities to the table, and when I go back to drop down the city combo box, the new cities I added aren't in the list. I researched tutorials and found that combo boxes need to be requeried in order to reflect the updated table. Here is the line of code that I put in the event procedure for the On Click event of the combo box:

Private Sub cboCity_Click()

Me.cboCity.Requery

End Sub

I also tried:
Me!cboCity.Requery
but this line of code doesn't work either. I get no code errors, but it doesn't requery.

Now I tried this in the After Update event as well with no luck. The table just doesn't want to requery itself after I've modified the city table. The only way I can get it to reflect the changes is if I close down the form completely and restart it, which is not something I want to do every time I add a new city.

Any suggestions?

Thank you,

Wayne.
Mar 29 '07 #1
12 21240
Rabbit
12,516 Expert Mod 8TB
Hi,

I have a combo box on a form with a list of cities in it based on a single field city table. I also have a command button on this form that opens up another form that allows the user to enter in new cities to the city table. Now, after i dd new cities to the table, and when I go back to drop down the city combo box, the new cities I added aren't in the list. I researched tutorials and found that combo boxes need to be requeried in order to reflect the updated table. Here is the line of code that I put in the event procedure for the On Click event of the combo box:

Private Sub cboCity_Click()

Me.cboCity.Requery

End Sub

I also tried:
Me!cboCity.Requery
but this line of code doesn't work either. I get no code errors, but it doesn't requery.

Now I tried this in the After Update event as well with no luck. The table just doesn't want to requery itself after I've modified the city table. The only way I can get it to reflect the changes is if I close down the form completely and restart it, which is not something I want to do every time I add a new city.

Any suggestions?

Thank you,

Wayne.
I've come across this too but I don't know why it won't work. So I usually end up using a Me.Refresh.
Mar 29 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
In the On Close event of the Add Cities form is when you need to requery the combobox.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2.  
  3.    Forms![FirstFormName]![cboCity].Requery
  4.  
  5. End Sub
Mary
Mar 29 '07 #3
Hi Rabbit,

Yeah it is strange. I even tried your Me.Refresh in my code. I put in in my click event on my combo box so when I click to open the combo list options, it should refresh the list immediately. hmmm, what event are you linking your Me.Refresh to?

Wayne.

I've come across this too but I don't know why it won't work. So I usually end up using a Me.Refresh.
Mar 29 '07 #4
Rabbit
12,516 Expert Mod 8TB
Hi Rabbit,

Yeah it is strange. I even tried your Me.Refresh in my code. I put in in my click event on my combo box so when I click to open the combo list options, it should refresh the list immediately. hmmm, what event are you linking your Me.Refresh to?

Wayne.
I put it right after the code that changes the listbox.
Mar 29 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Wayne you are using two different forms so the Me.Refresh won't work as you are refreshing the wrong form. Have you tried the code I gave you in post #3?
Mar 29 '07 #6
Again! Mary, you are two for two with my postings. Your code works perfectly. I should alert Rabbit of this code.

Thank you! :)

Best regards,

Wayne.

In the On Close event of the Add Cities form is when you need to requery the combobox.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2.  
  3.    Forms![FirstFormName]![cboCity].Requery
  4.  
  5. End Sub
Mary
Mar 29 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
No problem.
Mar 29 '07 #8
I replied to your last message as you made this message, so yes it does work :) And what are you doing up so early in Ireland, get back to bed!



Wayne you are using two different forms so the Me.Refresh won't work as you are refreshing the wrong form. Have you tried the code I gave you in post #3?
Mar 29 '07 #9
Check out Mary's solution, it works great.

Thanks again,

Wayne.

I put it right after the code that changes the listbox.
Mar 29 '07 #10
MMcCarthy
14,534 Expert Mod 8TB
I replied to your last message as you made this message, so yes it does work :) And what are you doing up so early in Ireland, get back to bed!
Haven't been to bed yet. I'm a vampire. I work through the night and sleep during the day. When I sleep that is. :rolleyes:
Mar 29 '07 #11
Rabbit
12,516 Expert Mod 8TB
Check out Mary's solution, it works great.

Thanks again,

Wayne.
I've already tried her solution. That and my listbox is on the same form that's calling the sub.
Mar 29 '07 #12
I just encountered the same problem. In my case, I change my values and save it to the records in one form (sort of a dialog box), then view the queried results in another form (stays open while I'm changing data through my dialog box).

Expand|Select|Wrap|Line Numbers
  1. RefreshForm.Requery
  2.  
I've tried the following suggestions:

Expand|Select|Wrap|Line Numbers
  1. Application.CurrentDb.QueryDefs.Refresh
  2. RefreshForm.Requery
  3.  
Expand|Select|Wrap|Line Numbers
  1. RefreshForm.Refresh
  2. RefreshForm.Requery
  3.  
However, none of them worked. The only thing that worked for me is to re-specify the form filter and turn it on.

Expand|Select|Wrap|Line Numbers
  1. RefreshForm.Filter = Filters
  2. RefreshForm.FilterOn = True
  3.  
Where RefreshForm is a Public Object variable set to the Form I want to update, and Filters is a Public String in which I stored the filter on which my Form Query is based. Maybe a parallel method may work--try re-specifying the RowSource property of the ComboBox within cboCity_Click().

Regards.
Jan 17 '13 #13

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

Similar topics

5
by: Scott | last post by:
I have created a form that has a few combo boxes on it. On the form I have ComboBoxA which selects data from a region, and ComboBoxB that selects individual locations within a selected region. I...
3
by: Yves | last post by:
Hi, I'm requering a combobox, and attempting to a) force it to have the first item selected instead of no item selected b) use values in hidden columns of the combobox for the selected item ...
2
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would...
3
by: Tony Dong | last post by:
Hi there I have three comboBoxs I need the first comboBox selected and fill the second comboBox, after second comboBox selected, it will fill the last comboBox, When I use selectedIndex change...
1
by: Matt | last post by:
Here is my problem. I am trying to get a combo box working that lists all the models of servers that we have. This combo box is just one of many text boxes that I have on my form. I am running a...
4
by: Miguel | last post by:
I have an order entry database with two forms. One is for new orders the other is to update orders. The forms are identical except that one is strictly order entry. On both forms are three sets of...
5
by: consonanza | last post by:
I am working on a report filter form. It has 2 combo boxes (cmboSelectSubject and cmboSelectCategory) to select criteria. Selecting an entry in combo 1 restricts the options available in combo 2....
6
by: zuchowra | last post by:
Hi everyone. I need help. I have a combo box in my form that i want to populate multiple text boxes after you select your selection in the combo box. Here is my set up. The Fields that need to be...
2
by: buddyr | last post by:
Hello, I am having trouble with two combo boxes working together. two tables table1 table2 table1 fields -number and name table 2 fields -code and number ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.