New in VBP Acces, How to execute a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I'm new programing in Acces, I have a form with tree chekboxes on it
(option0, option2, option4).
I want that if the chekbox 0 and 2 are chossen, Macro1 runs, I have the
folowing code giving me bad results (pd. I also have a command button and the
code is in the command_click event):

Private Sub Command7_Click(Cancel As Integer)
If Option0 = 1 And Option2 = 1 Then
DoCmd.RunMacro "Macro1"
End If
End Sub

What am I doing wrong????
TIA
 
filo666 said:
Hi, I'm new programing in Acces, I have a form with tree chekboxes on it
(option0, option2, option4).
I want that if the chekbox 0 and 2 are chossen, Macro1 runs, I have the
folowing code giving me bad results (pd. I also have a command button and the
code is in the command_click event):

Private Sub Command7_Click(Cancel As Integer)
If Option0 = 1 And Option2 = 1 Then
DoCmd.RunMacro "Macro1"
End If
End Sub


If those are really check boxes (not in an Option Group
frame), then you need to check if they are True not 1:

If Option0 = True And Option2 = True Then
. . .
 
IT DOESN'T WORKS, APPEARS AN ERROR MESSAGE:
"The expression on Click you entered as the event property setting produced
the following error:
procedure declaration does not match description of event or procedure
having the same name".
 
Sorry, I missed that problem before. The Click event does
not provide a Cancel argument, get rid of it:
Private Sub Command7_Click()

If there's a problem in the macro, I won't be able to help
you beyond telling you to convert it to a VBA procedure.
 
tks Marshall, the macro isn't the problem, the problem was the (cancel as
integer), my program works just as expected
Thankyou very much
regards

Marshall Barton said:
Sorry, I missed that problem before. The Click event does
not provide a Cancel argument, get rid of it:
Private Sub Command7_Click()

If there's a problem in the macro, I won't be able to help
you beyond telling you to convert it to a VBA procedure.
--
Marsh
MVP [MS Access]

IT DOESN'T WORKS, APPEARS AN ERROR MESSAGE:
"The expression on Click you entered as the event property setting produced
the following error:
procedure declaration does not match description of event or procedure
having the same name".
 
Back
Top