Cancel button in a form

B

BCiel

I have a database where you first select a task by clicking a button from a
menu I created using a form. There is a report, query, form and macro all
connected to complete this task. When you click that button another form
pops up for you to insert information to run a report. At the bottom of that
form is an "OK" button and a "Cancel" button. When the "Cancel" button is
clicked, the query is still being called upon instead of the entire task
being cancelled.

The macro originally opens the form which then is supposed to call the query
when you click "OK". That button seems to be working fine.

Does anyone have any thoughts??
 
J

John W. Vinson

I have a database where you first select a task by clicking a button from a
menu I created using a form. There is a report, query, form and macro all
connected to complete this task. When you click that button another form
pops up for you to insert information to run a report. At the bottom of that
form is an "OK" button and a "Cancel" button. When the "Cancel" button is
clicked, the query is still being called upon instead of the entire task
being cancelled.

The macro originally opens the form which then is supposed to call the query
when you click "OK". That button seems to be working fine.

Does anyone have any thoughts??

Please post your code. We can't see it from here!
 
B

BCiel

Sorry. This is the coding for the Cancel button. It was set up using the
wizard.

Private Sub Cancel1_Click()
On Error GoTo Err_Cancel1_Click

Dim stDocName As String

stDocName = "Cust Call report Macro.Cancel"
DoCmd.RunMacro stDocName

Exit_Cancel1_Click:
Exit Sub

Err_Cancel1_Click:
MsgBox Err.Description
Resume Exit_Cancel1_Click

End Sub
 
J

John W. Vinson

Sorry. This is the coding for the Cancel button. It was set up using the
wizard.

Private Sub Cancel1_Click()
On Error GoTo Err_Cancel1_Click

Dim stDocName As String

stDocName = "Cust Call report Macro.Cancel"
DoCmd.RunMacro stDocName

Exit_Cancel1_Click:
Exit Sub

Err_Cancel1_Click:
MsgBox Err.Description
Resume Exit_Cancel1_Click

End Sub

Well, it's set up to run a macro (which I also cannot see) named Cust Call
report Macro.Cancel. I sort of doubt that you have such a macro!

What is it that you want to cancel? Editing this entire record, erasing the
user's work entirely? If so replace the two lines

stDocName = "Cust Call report Macro.Cancel"
DoCmd.RunMacro stDocName

with

Dim iAns As Integer
iAns = MsgBox("Cancel this record and erase the form?", vbYesNo)
If iAns = vbYes Then
Me.Undo
End If
 
J

Jason

If the code runs from the first button then cancel on the next form won't
work. I would use the code "After opening the second form) from the first
form and move it to the OK button on the second form.
 
B

BCiel

I do indeed have a macro called Cust Call Report Macro.Cancel!!

This form is setting up parameters for running a report. If you start to
fill in those parameters and decide you do not want to run the report, I just
want the "cancel" button to just close the form and not save or run anything.

I have set up an entire database that will track customers, vendors, sales
and commission data, run reports, etc. The cancel button works fine in all
of these places.

I am now trying to setup something similar in different database that will
track customer calls. This will also be a replicated database when the setup
is done.
 

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