macros running from forms with filtered records

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
 
K

Ken Snell

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?
 
J

John

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
 
K

Ken Snell

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.)
 
G

Guest

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.
 
K

Ken Snell

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.
 
J

John

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>




.
 

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