Prompt for input if another field is not blank

  • Thread starter Thread starter jh
  • Start date Start date
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.
 
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)
 
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.
 
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.
 
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)
 
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.
 
Back
Top