macros running from forms with filtered records

  • Thread starter Thread starter John
  • Start date Start date
J

John

I have problem with a macro. I want to prevent data input
on the form after a date has been in a date field. When
the form is activated, I apply a filter to only select
records for a particular department. The macro I use to
check if a date has been entered does not work.

I have a similar macro that gets called from a form where
the filter is not used and it works just fine.

What is required to get the macro to work from the form
with the filter applied?

John
 
Help us help you.....can you post some info about what the actions are in
the macro that's working and in the macro that's not? What is the macro
supposed to be doing?
 
In the macro check if a date has been entered in a date
ffield. If so, then no input is allowed on that paticular
record.

I call the macro at an ON Click' event. The macro does the
following:

Open Form
Len (forms!formname!fieldname) > 0 msgbox("noinput
allowed")
Cancel Event
Stop Macro

I use a similar macro for filtered records. the only
difference is the form name that is referenced.

thanks,

John
 
You don't say what is meant by "the macro doesn't work", but I'm guessing
what's "not working" is that the form is being opened no matter what, right?

Your order of the macro actions needs to be changed; don't open the form
until you've done the validation. Use a macro similar to this on the "on
click" event:

MacroName
Condition: Len(Forms!FormName!TextBoxName & "") = 0
Action: MsgBox
Message: No input allowed.

Condition: ...
Action: StopMacro

Condition: (blank)
Action: OpenForm
Form Name: FormNameToOpen
(etc.)
 
what happens is that I'm still able to enter data on the
record. It's like the condition Len(forms!...) > 0 is not
met.
 
Aas I noted, what you posted as the macro will not prevent you from entering
values into the second form. What your macro tries to do is to cancel the
"on click" event (which can't be canceled) after you've already opened the
form.

Try what I posted (three-step macro) in place of yours and see if that is
better.
 
will do. thanks
-----Original Message-----
Aas I noted, what you posted as the macro will not prevent you from entering
values into the second form. What your macro tries to do is to cancel the
"on click" event (which can't be canceled) after you've already opened the
form.

Try what I posted (three-step macro) in place of yours and see if that is
better.


--
Ken Snell
<MS ACCESS MVP>




.
 
Back
Top