Form Help

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
 
J

John Vinson

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] & "#"
 

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