Supplying a query with data from VBA

  • Thread starter Thread starter Jonathan Stratford
  • Start date Start date
J

Jonathan Stratford

Hi,

I'm trying to open a report based on a query using VBA. I
want to send the contents of a textbox on the form to the
report when i click on a button - i have the following
line to open the report

DoCmd.OpenReport "RSearchDate", acViewPreview

but i'm not sure how to send the value (txtdate.value) to
the report. Can anyone help me please?

Thanks in advance,
Jonathan
 
You should be able to reference the form control directly
in the query by inserting a reference to the form field
such as Forms!YourFormName!YourFieldName

But, this will append the value to every record, if you
have a lot of records this may not be desireable. I
would guess that you may be able to set your report
control equal to the same reference directly, but I
haven't tried it.

-Ted
 
Back
Top