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.
Expand|Select|Wrap|Line Numbers
- '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.
Expand|Select|Wrap|Line Numbers
- 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!