OpenQuery Method.

  • Thread starter Thread starter Tim Loeffelholz
  • Start date Start date
T

Tim Loeffelholz

If I want an end-user to be able to run a Data Sheet view
or even a report, how do I pass a date parameter to the
query?

I'm having the user enter a date 11/11/2003 into a Short
Date formatted Unbound text box. This should then open a
view (or report) to view all records that equal that date.

The general code:

"SELECT [Punch].[ID], [Punch].[Punch], [Punch].[PunchDate]
FROM Punch WHERE ((([Punch].[PunchDate])= Forms!
frmJavaDreams!txtMyDate))"

This is where txtMyDate is the manually entered date. I'm
not sure how the OpenQuery Method actually works. Please
help/advise! Thanks in advanced
 
What you need to do is to put your SQL string into a
string variable and then declare the record source of your
report to be that string.

for example in the Open Report event.

Dim stSQL as String

stSQL = "SELECT * FROM Punch "
stSQL = stSQL & "WHERE PunchDate= " & Forms!frmJavaDreams!
txtMyDate

me.RecordSource= stSQL

Code might need some tweaking but that should be about
right.

HTH
 
Back
Top