Using Macros to require data entry

C

Chi

Hi,
I would like to set up a macro to require data entry.

I have a form that has Main form and sub form.

One of the fields that located on the main form is CALL (yes/No type)

One of the fields located in the subform is CALLDATE field. It is wonderful
if soon I check CALL field located main form, it will pop up the message "
please enter CALLDATE field in subform".

If I don't check CAll field in the main form, no message pop up
Please help

Thanks
Chi
 
F

freakazeud

Hi,
try to adapt VBA (visual basic for applications). Macros are very limited
and cannot handle error handling.
Try this on the on click event or after update event of the checkbox in your
main form:

If Me.YourCheckBox = True Then
MsgBox("Please enter a value in CALLDATE")
Me!SubformName.Form.ControlName.SetFocus
End If

HTH
Good luck
 
K

Ken Snell \(MVP\)

This can be done using a Condition expression with the macro action of
MsgBox and then the action StopMacro. I am assuming that CALLDATE is a
control on the subform (a field is in a table, in a query, or in a form's
recordset; a control is on a form or a report).

Macro:
Condition: Len(Forms!FormName!SubformName!CALLDATE & "")=0
Action: MsgBox
Message: "Enter value in CALLDATE!"

Condition: ... (note: put three dots in the box)
Action: StopMacro

Note that FormName in the above expression is the name of the main form, and
SubformName is the name of the subform control (the control that actually
holds the subform object).
 
C

Chi

It works ! Thank you so much!

freakazeud said:
Hi,
try to adapt VBA (visual basic for applications). Macros are very limited
and cannot handle error handling.
Try this on the on click event or after update event of the checkbox in your
main form:

If Me.YourCheckBox = True Then
MsgBox("Please enter a value in CALLDATE")
Me!SubformName.Form.ControlName.SetFocus
End If

HTH
Good luck
 

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