Assign query results to fields on a form

G

Guest

I have a query that I open which has correct values.
I want to assign those values to fields on a form but I am getting an error
"Object Required".
Here is where I call the query:
stDocName = "qryUpdateTelcoAllocationSplit"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Here is how I am trying to assign the values of the query to the form:
Forms![frmAllocationSplit-ALL].[100030] =
Queries![qryUpdateTelcoAllocationSplit].[a100030]

Can anyone tell me what object I am missing?
Ron
 
D

Douglas J. Steele

You can't assign values to forms like that.

If the query returns a single row, you can use DLookup:

Forms![frmAllocationSplit-ALL].[100030] = _
DLookup("[a100030]", "qryUpdateTelcoAllocationSplit")

If it returns multiple rows, you'll need to put a criteria as the 3rd
argument in the DLookup function.
 

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