Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing a form

Status
Not open for further replies.
Jan 15, 2004
5
0
0
US
Hi,

I have 3 unbound items on a form. Each one depends on another. The first one is called Employee Name, the second one Account Name, the third Account ID. I have it so that the users select an Employee and then they choose from a list of Account Name associated with that Employee name and then they choose the Account ID associated with that Employee name and Account Name. My thing is that once the user makes all 3 selections he/she may want to select another Employee name, but then the Account names do not refresh so they are left with the list of account names associated with the previous Employee Name. Hope this makes sense. I am also attaching the refresh code.

Thanks!

Private Sub EmployeeName_OnChange()
Me.Form.Requery
End Sub

Private Sub AccountID_OnChange()
Me.Form.Requery
End Sub

Private Sub AccountName_OnChange()
Me.Form.Requery
End Sub
 
Not certain this will solve the problem, but I would change from OnChange, to AfterUpdate, to be sure the code is run after the user hits enter or tabs out of the field.

ChaZ

Ascii dumb question, get a dumb Ansi
 
Thought!!!

You might want to put a command button on the form called Clear or something like that. Then put your code in the On Click of the button and not use the code you currently have.

Look in Help under:

Refresh
Requery

An investment in knowledge always pays the best dividends.
by Benjamin Franklin
 
I just looked at your code again. I notice that it does a refresh on the form instead of the objects on the form. That probably won't work, since refreshing the form only checks to see if the record it is based on has changed.

So try this instead.

me.form![(Your text box name here)].requery


ChaZ

Ascii dumb question, get a dumb Ansi
 
I tried changing the code to:
Private Sub EmployeeName_OnChange()
Me.AccountListing.Form![EmployeeName].Requery
End Sub

Private Sub AccountID_OnChange()
Me.AccountListing.Form![AccountID].Requery
End Sub

Private Sub AccountName_OnChange()
Me.AccountListing.Form![AccountName].Requery
End Sub

It is still not refreshing.

I also tried a command button but that didn't work either.

Any other idea?
 
Accountlisting is your form name?

Drop it, and use me.form!Accountid.requery

And if that doesn't work then I am stumped.

ChaZ


Ascii dumb question, get a dumb Ansi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top