access report with vba

T

tonyrulesyall

I am using Access XP with vba code.

The detail view in my report increments first by companyid,
then by date.

I would like to have vba code with my report to do the following:

Open a query with the date in the textbox, as described above.
Perform a dlookup on these results.

I've used dlookups before, but they call the actual query, not a
specific range.
 
J

John W. Vinson

I am using Access XP with vba code.

The detail view in my report increments first by companyid,
then by date.

I would like to have vba code with my report to do the following:

Open a query with the date in the textbox, as described above.
Perform a dlookup on these results.

I've used dlookups before, but they call the actual query, not a
specific range.

No VBA is needed. Just use the optional third argument of the DLookUp()
function to specify the criteria:

=DLookUp("fieldname", "queryname", "datefield = #" & Me!txtDate & "#")

where txtDate is the name of the control containing the date that you want as
a criterion.
 

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