Requerying a form from a popup form

nosferatu26

Registered User.
Local time
Today, 04:05
Joined
Jul 13, 2015
Messages
57
hello,

I have a bounded formA controlled by a listbox. Everytime I select an item in the list box the after update event is called and I use the following code to update to the selected record:
Code:
 DoCmd.SearchForRecord , "", acFirst, "[Design_Change_Item_ID] = " & Me.FormAListbox
then I just requery all the other controls within FormA and everything has been running smooth that way.

Now, I have added a popup form, FormB, to assist the user in searching/filtering out items within the original listbox of formA. I didn't do this all on the original form due to the lack of available space.

FormB lets the user filter out the list box and then they can select the desired item in a replica listbox within FormB when their criteria is met. When this selection happens, Ideally I would like FormA to be getting updated based on the selection from within the FormB listbox. To do this, I have been doing something like this for the FormB listbox afterupdate event:
Code:
 Forms!FormA.Form!crList = Me.crList
Forms!FormA.Form!changeList.Requery
 'Forms!FormA!SBFM_changeRequest.Refresh
 'Call Forms.FormA.Form.crList_AfterUpdate
The commented out lines throw 'action not available for object' errors.

The first two lines actually do update the listbox of FormA but the rest of the fields in the form don't update because the form is still bounded to the previous selection of listboxA. I was hoping to just change the selection with vba and then call the afterupdate event of the other form, essentially mimicking a user manually clicking that record; which would call afterupdate. Unfortunately I haven't been having any luck.


This was difficult to articulate, hopefully it isn't worded too poorly. If anyone can help me update the bounded ID as well as the listbox then I would greatly appreciate it!
 
In order to call the after update event of the listbox from the other form, you'd have to change Private to Public.
 
I have made the sub public and changed the code where I call it to:
Code:
 Call Forms.FormA.crList.AfterUpdate
Now I am receiving an "Object doesn't support this property or method" error.
 
Last edited:
Try

Forms!FormA.crList_AfterUpdate
 
AWESOME it works. at first I got an error but for future reference I had to make sure FormB was bounded as well; despite none of the controls being bounded.. Thank you very much!!!
 
Happy to help! FWIW, like Uncle I'd typically make a little function and call it from both places, but your method should work fine.
 
Ive just noticed one thing that you may be able to further help me with, there are two bounded controls on the form that still aren't getting updated with the rest of the form. when I manually click on new items in the FormA crList they update fine but when I try to do it with vba it doesn't work, even in the crList_afterupdate event. Tried to refresh them and requery them and nothing.

Any thoughts?
 

Users who are viewing this thread

Back
Top Bottom