can't recreate a msgpopup on checkbox value

R

Robert Blackwell

On a form, there is a checkbox to flag for bad addresses. When the record
loads a msg box popsup if the box is checked. I'm trying to duplicate it for
another similar function. So far, I can make the new checkbox and it works
fine. However, when I add the code to run the macro it ruins my whole form
so it will not even load.

Here's the code for the original check box
Private Sub ConAddressAlert_Click()

End Sub

Private Sub Form_Current()
If ConAddressAlert = True Then
DoCmd.RunMacro "mcrAddressAlert"
End If

End Sub

Here's what I've added for my new checkbox

Private Sub BadAccount_Click()

End Sub

Private Sub Form_Current()
If BadAccount = True Then
DoCmd.RunMacro "mcrBadAccunt"
End If

End Sub

If I delete my code section it works again.


When I add my code and try to run the form, I get 2 little windows titled

[Enter Parameter Value]
Forms!frmContacts!SearchName
TEXTBOX
[OK] [Cancel]

[Enter Parameter Value]
Forms!frmContacts!SearchBusiness
TEXTBOX
[OK] [Cancel]

Then anotherbox

[Company Contacts]
(i) The expression On Open you entered as the event property setting
produced the following error: Ambiguous name detected:Form_Current.

*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.
[OK]
 
R

Rick B

You don't need two Form_Current sections. You need to put them all in
one....
Private Sub Form_Current()
If ConAddressAlert = True Then
DoCmd.RunMacro "mcrAddressAlert"
End If

If BadAccount = True Then
DoCmd.RunMacro "mcrBadAccunt"
End If

End Sub

Also, why do you have "click events for your checkboxes, but no code in the
events?
Private Sub ConAddressAlert_Click()

End Sub



Fianlly, why are you running a macro? If you just want a box to pop up, it
seems to me that it would be cleaner and easier to add a line to your code
to pop up a msgbox. Your current method requrees you to go look at the
macro just to get an idea of what your code is doind. Seems kinda silly in
my opnion.

Hope that helps,

Rick b




Robert Blackwell said:
On a form, there is a checkbox to flag for bad addresses. When the record
loads a msg box popsup if the box is checked. I'm trying to duplicate it for
another similar function. So far, I can make the new checkbox and it works
fine. However, when I add the code to run the macro it ruins my whole form
so it will not even load.

Here's the code for the original check box
Private Sub ConAddressAlert_Click()

End Sub

Private Sub Form_Current()
If ConAddressAlert = True Then
DoCmd.RunMacro "mcrAddressAlert"
End If

End Sub

Here's what I've added for my new checkbox

Private Sub BadAccount_Click()

End Sub

Private Sub Form_Current()
If BadAccount = True Then
DoCmd.RunMacro "mcrBadAccunt"
End If

End Sub

If I delete my code section it works again.


When I add my code and try to run the form, I get 2 little windows titled

[Enter Parameter Value]
Forms!frmContacts!SearchName
TEXTBOX
[OK] [Cancel]

[Enter Parameter Value]
Forms!frmContacts!SearchBusiness
TEXTBOX
[OK] [Cancel]

Then anotherbox

[Company Contacts]
(i) The expression On Open you entered as the event property setting
produced the following error: Ambiguous name detected:Form_Current.

*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.
[OK]
 

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