Mar 23 2021 11:00 AM
I have a multi-user Access application -- each user has a client piece locally, all looking at a single Access database with the table data on a company network.
A form on that client application (let's call it Form1) has a number of objects, including a list box and several buttons. The form itself is unbound. One button has some code for the OnClick event, and all the VBA code behind the click event does is simply open open another form (call it, Form2). But, when I click that button on Form1 to open Form2 (which is also an unbound form), I can see that the list box on Form1 requeries (or refreshes -- I can't tell). There is nothing in the VBA code to requery the listbox on Form1.
Has anyone ever encountered such an anomaly or have any thoughts on what might be causing this anomaly?
Mar 23 2021 11:57 AM
Unfortunately, without SEEING the actual code, it's impossible to guess what might be happening.
To share the code, you can open the form in design view and select the VBA for the button's click event. Copy it all and paste it here. That way someone might be able to spot a line that could be causing this.
Mar 23 2021 01:09 PM
Thanks for the prompt reply. Here is the code, but it's really amazingly simple..
Private Sub Command6_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmContractAdd"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
Mar 23 2021 01:18 PM
Mar 23 2021 01:26 PM
Also, what happens in that second form, "frmContractAdd"? Is it adding a new contract to the table which is also the row source for this list box, by any chance?
Mar 23 2021 01:27 PM
Mar 23 2021 01:30 PM
Thank you. That was going to be my suggestion, in fact. So you see this requery even without closing the second form and BEFORE using it to add a new contract?
Mar 23 2021 01:37 PM
Mar 23 2021 01:45 PM
One more test comes to mind then. Open the contract form, then immediately close it without adding a new contract or doing any of the other validation. Simply open and close it. Does that still cause the unintentional requery?
Keeping in mind that processing in the calling form would be suspended until the called modal is closed, is there possibly some other event in the calling form that is pending until the contract form closes again? Maybe a timer event?
Mar 23 2021 01:53 PM
Mar 23 2021 02:09 PM
@RichNewman hm. That suggests the problem is not in the called form, then, but in the calling form. It is requerying the list box based on some internal event. As soon as it loses focus to the message box or to the called popup, something forces that requery. What other event(s) are in that form? Anything that could be going on there?
Also, is this on a subform or in a main form? It occurs to me that subforms do exhibit that repeated requery behavior when loading. Is that possibly involved?
Mar 23 2021 02:18 PM
Mar 25 2021 08:13 AM
I wonder if you've found the place where the requery is being triggered. If you'd like, I could take a look. Can you provide a sample copy of the accdb with any personal or confidential data removed?