query refresh on a form

  • Thread starter mark_jm via AccessMonster.com
  • Start date
M

mark_jm via AccessMonster.com

I have a form which has a lookup control.

The from "registrationform" has a field "companyname". companyname is in a
table "registrationtable", and looks up on field "owner" in table
"ownerstable"

When using the form "registrationform", I select the company name via the
lookup field from table"ownerstable".

I the owner is a new entry in table "owners tabel", I have a double click
event which opens an input form in add mode to ad tyhe owner to "ownerstabel".


That works great, but when I return to the original form, the new owner (
which was just input) dosnt appear in the list.

I think I ned to refresh the query which is the control source of the form in
question.

How do I refresh the query, as part of the double click event?
Or can I refresh when the field "companyname" gets the focus?
 
A

Allen Browne

Use the AfterUpdate event procedure of the input form to requery the combo
on the original form.

1. Open the input form in design view.

2. Open the Properties box.

3. Making sure you are looking at the properties of the form (not of a text
box), locate the AfterUpdate property (on the Event tab of the properties
box.)

4. Set the property to:
[Event Procedure]

5. Click the Build button (...) beside this.
Access opens the code window.

6. Set up the code like this:
Private Sub Form_AfterUpdate()
If CurrentProject.AllForms("registrationform").IsLoaded Then
Forms!registrationform!companyname.Requery
End If
End Sub

7. If you also need to tell the combo when a company is deleted, set the
form's AfterDelConfirm event procedure up like this;

Private Sub Form_AfterDelConfirm(...
If Status = acDeleteOk Then
Call Form_AfterUpdate
End If
End Sub
 
G

Golfinray

Try Me.Requery after you existing code. The form should automatically requery
for you, but for some reason it may not be.
 
M

mark_jm via AccessMonster.com

Thanks for the advice, I will tyr it
Try Me.Requery after you existing code. The form should automatically requery
for you, but for some reason it may not be.
I have a form which has a lookup control.
[quoted text clipped - 16 lines]
How do I refresh the query, as part of the double click event?
Or can I refresh when the field "companyname" gets the focus?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top