Referencing Form Variables in a Query

G

Guest

I would like to know how to get field values from a query onto fields in the
form. I query for two fields in a listbox, where one field goes into the list
box itself and the other field is to be sent to a textbox in the form. How is
this done? Also, How do I reference a form field in a query?
 
G

Guest

This is how you reference a form's text box in a query. In the query you
built, you need to put something in the field you want to reference like
[Enter Value]

Set dbs = CurrentDb()
Set qdfTarget = dbs.QueryDefs("qselMyQuery")
qdfTarget.Parameters(0) = Me.txtMyTextBox
Set rstTarget = qdfTarget.OpenRecordset(dbOpenSnapshot, dbReadOnly)

To get the fields from the query to the form, you will either have to use a
bound form where the fields always show up in the form, or you will have to
use some code somewhere to put the values in the form. Not knowing enough
about what you are doing, I can't give a good answer.

One other thing, please learn and use the correct terminology. It helps us
understand your question better. For example, Forms do not have fields, they
have controls.

Hope this will help at least a little
 

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