Prompt for input if another field is not blank

J

jh

I have a subform entitled "SLsubform". I need to prompt
the user for information if a field is not null. So...

If "ActualEnddate" is Not Null, then prompt user to put in
a Y or N in the field "SpecMet".

If "ActualEnddate" is Null, then don't allow user to put
in a Y or N in the field "SpecMet".

Hope this is enough info. If not, let me know. Thanks in
advance.
 
J

John Vinson

I have a subform entitled "SLsubform". I need to prompt
the user for information if a field is not null. So...

If "ActualEnddate" is Not Null, then prompt user to put in
a Y or N in the field "SpecMet".

If "ActualEnddate" is Null, then don't allow user to put
in a Y or N in the field "SpecMet".

Hope this is enough info. If not, let me know. Thanks in
advance.

You'll need some VBA code in the BeforeUpdate event of SLsubform;
untested air code...

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me!ActualEnddate) Then
If Not IsNull(Me!SpecMet) Then
MsgBox "You cannot enter anything in SpecMet", vbOKOnly
Cancel = True
Me!SpecMet.SetFocus
End If
Else
If IsNull(Me!SpecMet) Then
MsgBox "Please specify a SpecMet value", vbOkOnly
Cancel = True
Me!SpecMet.SetFocus
End If
End If
End Sub


John W. Vinson[MVP]
(no longer chatting for now)
 
J

jh

Thanks for the info, we are certainly on the right path.
However, I am getting an error.

I tried to test it by putting in an ActualEndDate and it
prompts me to "Please specify a SpecMet value". But when
I click OK, it gives me:

Run-time error '438'
Object does not support this property or method

When I press Debug, it is highlighting the Me!
SpecMet.SetFocus.

Then I commented out the Me!SpecMet.SetFocus and it seems
to be working.

Should I have commented this out?

Thanks.
 
G

Guest

I meant to say, I tried to test it by putting in an
ActualEndDate and not putting in anything in SpecMet. It
does give me the prompt to "Please specify a SpecMet
value".

But when I click OK, it gives me:

Run-time error '438'
Object does not support this property or method

When I press Debug, it is highlighting the Me!
SpecMet.SetFocus.

Then I commented out the Me!SpecMet.SetFocus and it seems
to be working.

Should I have commented this out?

Thanks.
 
J

John Vinson

I meant to say, I tried to test it by putting in an
ActualEndDate and not putting in anything in SpecMet. It
does give me the prompt to "Please specify a SpecMet
value".

But when I click OK, it gives me:

Run-time error '438'
Object does not support this property or method

When I press Debug, it is highlighting the Me!
SpecMet.SetFocus.

Then I commented out the Me!SpecMet.SetFocus and it seems
to be working.

Should I have commented this out?

Since I cannot see your form, and do not know what controls you have
on it, I WAS GUESSING. Perhaps I should have made it clearer that I
was doing so!

The SetFocus was intended to put the cursor into the textbox (if there
is one) into which the user should have entered Y or N. If that
control has a different name on your form, use that name; if there is
some other manner in which the field SpecMet is updated, do something
appropriate *for your form*.


John W. Vinson[MVP]
(no longer chatting for now)
 
J

jh

This worked perfectly! Thank you so-oo much. I just
changed the name of the field to be SpecMet and it worked
like a charm.
 

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