Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing date Param to Access

Status
Not open for further replies.

lrfcbabe

Programmer
Jul 19, 2001
108
US
Is there a trick for passing date parameters to Access?
I have in a query in Access to look for dates "Between[Beginning Date] And [Ending Date]". This returns a recordset but the dates are way off.
Here is the Function.

Private Function Get_QueryDate(QName As String)
Dim Q As QueryDef
Dim db As Database
Dim rs As Recordset
Dim fromdate As Variant
Dim todate As Variant

Debug.Print QName
Debug.Print txtDateFrom.Text
Debug.Print txtDateTo.Text
fromdate = txtDateFrom.Text
todate = txtDateTo.Text
Set db = DBEngine.Workspaces(0).OpenDatabase(strDBname)
Set Q = db.QueryDefs(QName)
Q.Parameters("Beginning Date") fromdate '4/30/00
Q.Parameters("Ending Date") = todate '7/30/00
Set rs = Q.OpenRecordset()
Set frmMain.Data1.Recordset = rs
'Unload Me
End Function
 
Did you try this?

Dim FromDate as Date
Dim ToDate as Date

I've also seen where a query on two dates that range before and after 01/01/00 can return some strange results, and I'm not sure of a fix for that without writing your own comparison function.

-Mike
Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top