Using Macros to require data entry

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

Guest

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
 
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
 
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).
 
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
 
Back
Top