Hello everyone, I'm new to the forum and hope I can gather some great help from anyone willing to provide it. Here is my dilemma. I'm working on my search form and have an unbound textbox which lists several different queries that the user can run based on a date range in separate fields on the form. Since I have several different queries listed, I need to use an IF statement to ensure the correct query is run when the search button is clicked. As I'm just starting, I only have one if statement. Once I get this one working, I'll add the others. Here is the code behind my search button.
Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.SetWarnings False
If Me.txtQueryChooser = "Form 1" Then
stDocName = "frm_Form 1"
stLinkCriteria = “[Date]” = Between [Forms]![frm_Search]![txtStartDate] And [Forms]![frm_Search]![txtEndDate]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frm_Search"
End If
DoCmd.SetWarnings True
Exit_cmdSearch_Click:
Exit Sub
Err_cmdSearch_Click:
Resume Exit_cmdSearch_Click
End Sub
I appreciate any help anyone can give. Thanks!
Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.SetWarnings False
If Me.txtQueryChooser = "Form 1" Then
stDocName = "frm_Form 1"
stLinkCriteria = “[Date]” = Between [Forms]![frm_Search]![txtStartDate] And [Forms]![frm_Search]![txtEndDate]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frm_Search"
End If
DoCmd.SetWarnings True
Exit_cmdSearch_Click:
Exit Sub
Err_cmdSearch_Click:
Resume Exit_cmdSearch_Click
End Sub
I appreciate any help anyone can give. Thanks!
Last edited: