Hello all,
I would like to develop a date search from Form in Access. Here is the sample of previous search coding I have developed used the help of experts on this forum.
I do want to develop something similar. From my research I gathered something like this that would go under the cmbSearch_Click function
- Date is the title of the date column and Entry is the title of the Table where the dates are stored.
Here is my previous thread here to see how I am developing the search function
http://bytes.com/forum/showthread.php? p=3178305#post3 178305
Now the problem is to give the user a message if he enters the date is wrong format...I don't know where exactly that msg code would go or how to check if the user entered wrong date. And please do check if my code "looks right" too.
Thanks in advance for your time!
I would like to develop a date search from Form in Access. Here is the sample of previous search coding I have developed used the help of experts on this forum.
Code:
'Approach to CSR
If Not IsNull(txtSearchField12) Then
GCriteria4 = GetResults(Me.txtSearchField12, "[ApproachtoCSR]", Me.optSearch)
If GCriteria = "" Then
GCriteria = GCriteria4
Else
GCriteria = GCriteria & " AND " & GCriteria4
End If
End If
'Publisher
If Not IsNull(cboSearchField2) Then
GCriteria5 = GetResults(cboSearchField2.Value, "[Publisher]", Me.optSearch)
If GCriteria = "" Then
GCriteria = GCriteria5
Else
GCriteria = GCriteria & " AND " & GCriteria5
End If
End If
Form_frmInput.RecordSource = "select * from Entry where " & GCriteria & ";"
Form_frmInput.Requery
If Form_frmInput.NewRecord Then
MsgBox "No matching records found. Try less restricted search criteria", vbOKOnly, "No Matches Found"
Else
MsgBox "Results have been filtered.", vbOKOnly, "Search Successful"
DoCmd.Close acForm, "frmSearch"
End If
- Date is the title of the date column and Entry is the title of the Table where the dates are stored.
Code:
If Not IsNull(txtDate) AND IsDate(txtDate) Then
GCriteria6 = "SELECT Entry.* FROM Entry" _
& " WHERE Format([Date],'dd/mm/yyyy')= #" _
& Format(txtDate, "dd/mm/yyyy") & "#"
If GCriteria = "" Then
GCriteria = GCriteria6
Else
GCriteria = GCriteria & " AND " & GCriteria6
End If
End If
http://bytes.com/forum/showthread.php? p=3178305#post3 178305
Now the problem is to give the user a message if he enters the date is wrong format...I don't know where exactly that msg code would go or how to check if the user entered wrong date. And please do check if my code "looks right" too.
Thanks in advance for your time!
Comment