1
votes

I have an Access form that has four fields. Two unbound textboxes and two Bound Comboboxes.

The user is meant to enter a country name into textbox1 and Combobox1 underneath gives only the one option that matches in my Country Table.

Then the user inputs a region name into textbox2 and Combobox2 gives only the matching region.

This was working fine, however, when I moved onto a new record, the textbox values remained. Even when I deleted the contents of the textboxes and typed a different country name or region name, the comboboxes still referenced the old value.

I found a solution to this by adding code

Private Sub Textbox1_AfterUpdate()
Me.Combobox1.Requery
End Sub

Private Sub Textbox2_AfterUpdate()
Me.Combobox2.Requery
End Sub

But it was still annoying me that I had to manually delete the old textbox values on the new record, so I found a solution to that and tested it on textbox1

Private Sub Form_Current()
Me.Textbox1 = ""
End Sub

This worked fine and textbox1 cleared when moving to a new record, but when I did the same to texbox2, I got the following error message

"The expression On Current you entered as the event property setting produced the following error:Ambigous name detected: Form Current"

Is there a way I can clear two texboxes on the same form?

Thanks

J

1
Put both lines in the same Current event. You can only have one Current event per form. You need to do a bit of reading.Fionnuala
Thanks @Fionnuala for you kind words. The solution you provided worked great for me. Thank you, thank you, thank you so much.... every day is a learning day:)jellybean1977

1 Answers

1
votes

Put both lines in the same Current event. You can only have one Current event per form.