using form field value for query

raychoy2k

Registered User.
Local time
Today, 12:32
Joined
Feb 24, 2003
Messages
29
I am trying to use a field value from the active record for a query in the "row source" property for a listbox. The query I entered works, but when I traverse to next or previous records, the query will not use the new field value from the current record to refresh the query. Is there a way to have the sql query refresh when I traverse to new records without using vb?
 
I am not using any events to trigger the query. I am assuming access automatically runs the query when the form is opened. This query is manually typed/entered in the "row source" property for a listbox.

It seems that this query only runs once by default. As soon as I open the form, the query runs and uses the current field value, which corresponds to record 1. But when I traverse to record 2, access does not re-run the query in the "row source" field to use the field value from record 2.
 
Run the query in the OnCurrent event of the form. It'll run every time you go to a different record.

Col
:cool:
 
I had no idea that you can run queries directly from the event properties. Let me give it a try thanks
 
I can't run that query in the onCurrent event because the query results are supposed to be used for the listbox "row source" property. Any other suggestions
 
If I understand you are trying to pass a value from the list box to the query. If so I used this from a combobox but should work the same I would imagine.

I put this in the criteria for where you want it passed.
[Forms]![frmName]![listBoxName]

Check out the example
 

Attachments

NO NO,

I am trying to take another value from the form (text box) and use it in a query (as a criteria) to retrieve the information I want listed in the listbox. Therefore, I have to run the query in the "row source" property of the listbox. Because queries returned in the "row source" property will populate the listbox with that data. Hopefully this makes sense
 
Sorry, but I dont know what you mean by re-query the listbox?
 
Thanks that helped alot.

I used a macro instead, but it lead me to the right direction. I am new to access. I am not having problems learning it, its just the lack of experience. Thanks for all the help everybody.
 

Users who are viewing this thread

Back
Top Bottom