OpenForm action canceled for unknown reason

G

Guest

I am using a command button on a form to open another form. I do not know why "The OpenForm action was canceled" error appears. Below is the code I'm using to open the form and also the On Open Event code I'm using on the form as it opens. I'm hoping someone can shed some light on the reason I'm getting the error.

Private Sub cmdEditCustomer_Click()
DoCmd.OpenForm "frmFindCorrectCustomer", OpenArgs:="Prospective"
DoCmd.Close acForm, "mnuProspectiveCustomers"
End Sub

The code stops and gives me the error at the first line of code. I put a Stop at the second line so I could find the problem. When the code stops, it shows that OpenArgs = Null. I don't know why. Below is the code I have when the other form is supposed to open.

Private Sub Form_Open()
Select Case OpenArgs
Case "Prospective"
Me.cmdFindCustomer.Caption = "Go To Prospective Customer Record"
Case "Active"
Me.cmdFindCustomer.Caption = "Go To Active Customer Record"
Case "Inactive"
Me.cmdFindCustomer.Caption = "Go To Inactive Customer Record"
Case Else
Me.cmdFindCustomer.Caption = "Go To Customer Record"
End Select
End Sub

I would appreciate any insight into the Runtime error (2501). THANK YOU!
 
F

fredg

I am using a command button on a form to open another form. I do not know why "The OpenForm action was canceled" error appears. Below is the code I'm using to open the form and also the On Open Event code I'm using on the form as it opens. I'm hoping someone can shed some light on the reason I'm getting the error.

Private Sub cmdEditCustomer_Click()
DoCmd.OpenForm "frmFindCorrectCustomer", OpenArgs:="Prospective"
DoCmd.Close acForm, "mnuProspectiveCustomers"
End Sub

The code stops and gives me the error at the first line of code. I put a Stop at the second line so I could find the problem. When the code stops, it shows that OpenArgs = Null. I don't know why. Below is the code I have when the other form is supposed to open.

Private Sub Form_Open()
Select Case OpenArgs
Case "Prospective"
Me.cmdFindCustomer.Caption = "Go To Prospective Customer Record"
Case "Active"
Me.cmdFindCustomer.Caption = "Go To Active Customer Record"
Case "Inactive"
Me.cmdFindCustomer.Caption = "Go To Inactive Customer Record"
Case Else
Me.cmdFindCustomer.Caption = "Go To Customer Record"
End Select
End Sub

I would appreciate any insight into the Runtime error (2501). THANK YOU!

Does it wok for you this way?

DoCmd.OpenForm "frmFindCorrectCustomer", , , , , , "Prospective"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top