Form Help

  • Thread starter Thread starter Froto
  • Start date Start date
F

Froto

I have used this code from default access wizard. What I
would like to add is a end date textbox, how would I
modify the below code to add this extra?

Thank you very much

Private Sub CmdSearchBtt_Click()
On Error GoTo Err_CmdSearchBtt_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SearchForForm"

stLinkCriteria = "[Date]=" & "#" & Me![txtstartdate]
& "#"
DoCmd.OpenForm stDocName, , , stLinkCriteria
txtstartdate = ""
Exit_CmdSearchBtt_Click:
Exit Sub

Err_CmdSearchBtt_Click:
MsgBox Err.Description
Resume Exit_CmdSearchBtt_Click

End Sub
 
I have used this code from default access wizard. What I
would like to add is a end date textbox, how would I
modify the below code to add this extra?

The stLinkCriteria is just a SQL Query WHERE clause without the word
WHERE. You can build a query which gets the results you want in the
query grid and view it in SQL view to get a model. In this case:

stLinkCriteria = "[Date]>=#" & Me![txtstartdate] & "#" _
& " AND [Date] <= #" & Me![txtenddate] & "#"
 
Back
Top