linking a button to two text boxes

mee100

New member
Local time
Tomorrow, 02:05
Joined
Apr 4, 2007
Messages
3
Hello all,

i have a button that need to open a new form but first it should search between two spacific dates (entered by the user through two text boxes). it always gives an "miss match error"
here is the code of the button:
*****************************************************
Private Sub Command101_Click()
On Error GoTo Err_Command101_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "view_sent_memo"

stLinkCriteria = "[date]=" & "#" & Me![Text3] & "#" And "[date]=" & "#" & Me![Text115] & "#"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command101_Click:
Exit Sub

Err_Command101_Click:
MsgBox Err.Description
Resume Exit_Command101_Click
End Sub
****************************************
how can i link the stLinkCriteria to two dates ? to get the information needed between those two dates?
Thank you.
 
Try:

stLinkCriteria = "between [date]=#" & Me![Text3] & "# And [date]=#" & Me![Text115] & "#"

Btw: You should give your objects useful names for example:
cmdOpenSentMemoForm; txtFromDate; txtToDate.
Then if another developer picks up your code then they will know what is going on!
 
still not working

:(
first of all, thank you for your reply but it didn't work
it gave me:
Syntax error (missing operator) in query expression.
 
:(
first of all, thank you for your reply but it didn't work
it gave me:
Syntax error (missing operator) in query expression.

I have found that the best way to deal with this sort of requirement is to have the date requirements within the query which I assume your form is based on. For instance in the Critera section of the date field enter the following :

Between [Enter Start date] And [Enter End Date]

This will run the query for the specified date(s) which will in turn cause your form to only display the data fitting the date range prompted for.

Hope this is of assistance

John Lee
 

Users who are viewing this thread

Back
Top Bottom