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!

select records from table based on date criteria

Status
Not open for further replies.

chainedtodesk

Programmer
Feb 26, 2003
112
US
i have a access 2003 database that stores requests for programming changes and updates. they have a date field for DueDates (mydate) if i look for one due date it works okay.

Private Sub Command12_Click()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "table1"
stLinkCriteria = "[mydate]=" & "#" & Me![Text0] & "#"
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

but i cant seem to get this to use a range (from and to dates) i tried

stLinkCriteria = "[mydate]=" & "#" & Me![Text0] & "#" or _
stLinkCriteria = "[mydate]=" & "#" & Me![Text1] & "#" or _
stLinkCriteria = "[mydate]=" & "#" & Me![Text2] & "#"
DoCmd.OpenForm stDocName, , , stLinkCriteria

text0-2 are incremental dates (short date format) but it errors out. before i go nuts can this be done? any help would be appreciated.
 
A more concise syntax is an IN clause
Code:
stLinkCriteria = _
"[mydate]IN (#" & Me![Text0] & "#,#" & Me![Text1] & "#,#" & Me![Text2] & "#)"

 
you may try this:
stLinkCriteria = "[mydate]=#" & Me![Text0] & "# OR " _
& "[mydate]=#" & Me![Text1] & "# OR " _
& "[mydate]=#" & Me![Text2] & "#"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top