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

Requery Combobox after Updating List in Another Form

I am using Microsoft Access 2007. I have a list in a dropdown combobox (Field_One) in a form (Form_One). Users have the option to click a button if the item they need does not appear in the combobox, and another form, (Form_Two) opens to which they can add the new item (in Field_Two).

After adding the new item in F_Two I want the combobox in F_One to requery without having to close and reopen F_One.

I think I can do this with an After_Update event, but to which object should the event apply? Or is there a better way to do it?

Thank you
Jul 28 '10 #1
6 1686
hype261
207 100+
@Organizer
There are numerous ways you can do this. One of the ways I have overcome this is to put some code in Form_Two On Close event. Form_Two would have to be a modal for this to work consistantly though.

This is just rough code, but should get you started.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2.  
  3.     If (IsLoaded("Form_One")) Then
  4.         Forms![Form_One]!myComboBox.Requery
  5.     End If
  6. End Sub
Jul 28 '10 #2
@hype261
Here is what happens when I try this.
F_Organizations is the real name of Form_One, OrgNameID is the combobox within F_Organizations that I want to have requeried.

Here is the text that I put in the On Close event for Form_Two.

Private Sub Form_Close()

If (IsLoaded(F_Organizations)) Then
Forms![F_Organizations]!OrgNameID.Requery
End If

End Sub

I get an error message that says "Compile Error: Sub or Function Not Defined" and the term "IsLoaded" is highlighted.

The combobox field is structured as a lookup in the table that underlies F_Organizations. Could this be the problem and would this code work only if the combobox was created within the form itself?
Jul 28 '10 #3
I found something online that says that IsLoaded needs to be defined, and to copy it from the Northwind database and paste it into the module. It doesn't appear that Northwind was loaded on this computer (someone else set it up for me - I had it on my previous computer) and also I don't know exactly what "paste it into the module" means. Does anyone have that code and can you tell me where to paste it?

Thank you.
Jul 28 '10 #4
hype261
207 100+
@Organizer
isLoaded is a common function that alot of Access programmers use. I am surprised that it hasn't be made a standard access function.

Here is the isloaded function from one of the apps at my work. I don't know if it is the same as the Northwind one.

Expand|Select|Wrap|Line Numbers
  1. Function IsLoaded(MyFormName)
  2. On Error GoTo Err_4
  3.  
  4.     '  Determines if a form is loaded.
  5.  
  6.     Const FORM_DESIGN = 0
  7.     Dim i As Integer
  8.  
  9.     IsLoaded = False
  10.     For i = 0 To Forms.Count - 1
  11.         If Forms(i).FormName = MyFormName Then
  12.             If Forms(i).CurrentView <> FORM_DESIGN Then
  13.                 IsLoaded = True
  14.                 Exit Function  ' Quit function once form has been found.
  15.             End If
  16.         End If
  17.     Next
  18.  
  19. Exit_4:
  20.     Exit Function
  21.  
  22. Err_4:
  23.     MsgBox Error$
  24.     Resume Exit_4
  25.  
  26. End Function
Just copy the code and create a new module in Access and paste it in.
Jul 28 '10 #5
@hype261
One problem solved. I don't get the error message now.

I got an error message and had to add "End Function" after "Resume Exit_4" but then it worked (perhaps that would have been obvious to most people - I'm pretty much of a novice with code).

However, it still doesn't seem to requery. If I make a change to an existing entry in Form_Two, those changes do show up in F_Organizations. But if I actually add a new entry, that still doesn't show up until I close and reopen F_Organizations.

I did check to be sure my event procedure is still there on close for Form_Two, and it is.

Thank you.
Jul 28 '10 #6
hype261
207 100+
@Organizer
Have you made sure that the new entry was saved to the table or isn't being filtered out in the query for the combo box?
Jul 28 '10 #7

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

Similar topics

1
by: David | last post by:
Hi, I have a form which requires Serial Numbers to be loaded from another form. When I press a button, another form opens with a list of Serial Numbers. I have the record selectors enabled. ...
2
by: F. Michael Miller | last post by:
I need to requery a subform from a third form and can't seem to get it to work. frmForm1 has frmAddress as a subform. The button cmdReviseAddress opens the form frmUpdateAddress where all of my...
11
blyxx86
by: blyxx86 | last post by:
I can't seem to get this figured out. I am trying to requery another form after adding new information to a table that a cboList is created from. So, I have a combo box that has Sales personnel,...
5
by: ApexData | last post by:
I have a ComboBox, when dblClicked, displays the combobox's row content in a continuous subform. Changes can be made to this content in the subform and then closed. The ComboBox needs to be...
2
by: hlebforprimeminister | last post by:
Hi I am having a problem with the visualbasic for requerys in access. I have had a look at some of the other discussions but i can't find an answer. So, my problem is this. I have a form...
0
by: adalyc | last post by:
I NEED SOME GUIDENCE WITH UPDATING A COLLECTION OF ITEMS IN A LIST BOX WHEN THE USER CLICKS ON A BUTTON FROM ANOTHER FORM,, i HAVE LISTED THE PROBLEM PARTIALLY. I fIGURED OUT MOST OF THE PROBLEM...
2
by: SePp | last post by:
Hi all. I want to refresh a Datagrid from another form. For Example I have a Datagrid in that I want to edit data. The user has the ability to press a button to change these data. A new Form...
1
by: viranadim | last post by:
I am having problems with attempting to filter a form based on criteria selected in a combo box from another form. I am attempting to filter a form called "Ford CheckList" that is based on a table...
1
by: viranadim | last post by:
I am having problems with attempting to filter a form based on criteria selected in a combo box from another form. I am attempting to filter a form called "Ford CheckList" that is based on a table...
1
by: menyki | last post by:
am still finding it difficult as a new java user. am designing a software that has multiple forms, controls such as combobox and so on and finding it difficult to do the following. i want some...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.