Tom W
Tom W

Reputation: 1

How to Refresh all in Microsoft Access / VBA

I have a form with 3 cascading combo boxes that allow the user to select a given work site, equipment pakage, and specific equipment item.

I've done this with three queries, using the method from this video: https://www.youtube.com/watch?v=eFOACVzMjiQ

However, I need to be able to output the equipment details such as width, length, motor power to text boxes so the user can copy that information into other documents.

The cascading combo boxes are working, however the text fields do not update upon a new equipment selection until I press the "Refresh All" button in the Ribbon.

I have tried using Me.Refresh and Me.textField.Requery, triggered by "after update" on the last combo box, but this doesn't work, or triggers a Compile error "invalid qualifier"

Here's all the code I currently have:

Option Compare Database

Private Sub cbProjectCode_AfterUpdate()
    Me.cbPackageNo.Requery
End Sub

Private Sub cbPackageNo_AfterUpdate()
    Me.cbEquipmentNo.Requery
End Sub

Private Sub cbEquipmentNo_AfterUpdate()
    Me.Refresh
End Sub

Upvotes: -1

Views: 89

Answers (1)

Gustav
Gustav

Reputation: 56016

No code is needed.

Create the three textboxes and bind them using these ControlSources respectively:

=[cbProjectCode]

=[cbPackageNo]

=[cbEquipmentNo]

These will, at any time, reflect the current values of the comboboxes.

If you need the value from another column than the bound, specify which column to retrieve:

=[cbPackageNo].[Column](1)

Note, that Column(0) is the first column.

Upvotes: 0

Related Questions