Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Function (Problem with Date)

Status
Not open for further replies.

jimjaix

MIS
Jan 14, 2011
17
US
Hi, I created the following function on a button.

Private Sub Search_Click()

If (IsNull(cboType)) Or (IsNull(txtCriteria)) Then
MsgBox "Please select search type", vbOKOnly, "Please select search type"
ElseIf [cboType] = "Last Name" And [txtCriteria] > "" Then
DoCmd.OpenForm "frmSearchLastName"
ElseIf [cboType] = "First Name" And [txtCriteria] > "" Then
DoCmd.OpenForm "frmSearchFirstName"
ElseIf [cboType] = "Call Date" And [txtCriteria] > "" Then
DoCmd.OpenForm "frmSearchDate"
End If

End Sub

And I have forms that point to a query and pick up the txtCriteria that I typed and return me the list of match result.

My questions is how can I create a date range search when cBoType is "Call Date" and click on Search Button, prompt me to enter date range?

And on my query, I am using...
Like [Forms]![frmSearch].[txtCriteria] & "*
 
Assuming that [txtCriteria] would hold the start date of the date range, you could have a hidden text control on the form which is only made visible and receives focus if [cboType]="Call Date" which would be used to enter the end date of the date range.

In this case you might need a separate query providing data for frmSearchDate which searches for dates "Between [Forms]![frmSearch].[txtCriteria] And [Forms]![frmSearch].[your new text field]
 
Sweet, I did what you told me and created the code on my own. I am so new to coding : (
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top