OpenQuery Method.

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
 
J

Joe

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
 

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