P
Pete Provencher
Using Access 2000:
I have a form that has two unbound combo boxes that allow me to select a
parameter for a query by form.
I use a command button for each to start the process.
This first one works:
Option Compare Database
Private Sub cbOrderNumber_Click()
Dim strWhereON As String
stFormNameON = "frmDisplaySearchOrderNumber"
If Not IsNull(Me.CmbOrderNumber) Then
strWhereON = "[OrderNumber] =""" & CmbOrderNumber & """"
DoCmd.OpenForm stFormNameON, WhereCondition:=strWhereON
DoCmd.Close acForm, "frmSearch"
Else
MsgBox "You must select an Order Number."
End If
End Sub
I copied this code to (which I learned how to do from a answer given by Jim
Viescas in an earlier question) the next command button and made the
applicable changes:
Option Compare Database
Private Sub cbDateTaken_Click()
Dim strWhereD As String
stFormNameD = "frmDisplaySearchDateTaken"
If Not IsNull(Me.CmbDateTaken) Then
strWhereD = "[DateTaken] =""" & CmbDateTaken & """"
DoCmd.OpenForm stFormNameD, WhereCondition:=strWhereD
DoCmd.Close acForm, "frmSearch"
Else
MsgBox "You must select a Date."
End If
End Sub
When I click on the command button for this one I can an error on the line
DoCmd.OpenForm stFormNameD, WhereCondition:=strWhereD
Run-time error 2501
OpenForm action was canceled.
I looked at the value for stFormNameD and it was correct
I looked at the value for strWhereD and it set the correct parameter
I just can't figure this out and hope someone can see the error of my ways.
Pete Provencher
I have a form that has two unbound combo boxes that allow me to select a
parameter for a query by form.
I use a command button for each to start the process.
This first one works:
Option Compare Database
Private Sub cbOrderNumber_Click()
Dim strWhereON As String
stFormNameON = "frmDisplaySearchOrderNumber"
If Not IsNull(Me.CmbOrderNumber) Then
strWhereON = "[OrderNumber] =""" & CmbOrderNumber & """"
DoCmd.OpenForm stFormNameON, WhereCondition:=strWhereON
DoCmd.Close acForm, "frmSearch"
Else
MsgBox "You must select an Order Number."
End If
End Sub
I copied this code to (which I learned how to do from a answer given by Jim
Viescas in an earlier question) the next command button and made the
applicable changes:
Option Compare Database
Private Sub cbDateTaken_Click()
Dim strWhereD As String
stFormNameD = "frmDisplaySearchDateTaken"
If Not IsNull(Me.CmbDateTaken) Then
strWhereD = "[DateTaken] =""" & CmbDateTaken & """"
DoCmd.OpenForm stFormNameD, WhereCondition:=strWhereD
DoCmd.Close acForm, "frmSearch"
Else
MsgBox "You must select a Date."
End If
End Sub
When I click on the command button for this one I can an error on the line
DoCmd.OpenForm stFormNameD, WhereCondition:=strWhereD
Run-time error 2501
OpenForm action was canceled.
I looked at the value for stFormNameD and it was correct
I looked at the value for strWhereD and it set the correct parameter
I just can't figure this out and hope someone can see the error of my ways.
Pete Provencher