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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pretty Simple Question

Status
Not open for further replies.

WarrenB

Programmer
Feb 7, 2001
38
GB
Hi, I'm reasonably new to access but I think i'm over looking something very simple. I have a query set-up to retrieve dates matching a certain number (account number to be exact), both of which are stored in the same table. So in this query I have the account number field, and the date field. Now I want the search to be based on what is entered in a text box (say text1) within a form (say called form1). Therefore under account number I have set the criteria to [Forms]![form1]![text1] . Now I have the query set up to run "on exit" from text1 (done via a macro). However, despite the fact it should my query is returning nothing every time.

However, when I run the query manually from within access and it asks me to enter the parameter manually, it returns results as expected. Does anyone know what I am doing wrong?

Thanks a lot =================
Warren Brown
wazzer@btinternet.com
=================
 
Try changing your macro execution from On Exit to On Lost Focus. Access online help states: "Within a record, changed data in each control is updated when the control loses focus or when the user presses ENTER or TAB."

Also, you could try running the macro from the AfterUpdate event.
 
Also from the On-Line Help article on Event Order:

When you enter or change data in a control on a form and then move the focus to another control, the BeforeUpdate and AfterUpdate events occur:

BeforeUpdate => AfterUpdate

The Exit and LostFocus events for the changed control occur after the BeforeUpdate and AfterUpdate events:

BeforeUpdate => AfterUpdate => Exit => LostFocus


So using the On Exit event should be as appropriate as using the AfterUpdate event.

Lightning

 
Warren, I did a quick test of your scenario using AfterUpdate, OnExit, and LostFocus, and the associated macro/query worked properly in each case. I suspect you have some other problem. Check your spellings, and check the data types of the date field in your database and on your form to make sure they match.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top