Restrict data entry into form field

G

Guest

How do I disable entry of data into form field C unless there is data in form
fields A and B? Also, is there a way to display a warning box as soon as
someone places the cursor in or moves the mouse over field C?
 
G

Guest

On the Got focus event of field C you can write the code

If IsNull(Me.[Field A]) Or IsNull(Me.[Field B]) then
msgbox "Must enter value in fields A and B"
Me.[Field A].SetFocus
End If
=========================
And I assume that you might want some code, to delete the value from field C
incase the value from fields A and B were deleted

On the After update event of fields a and b, write the code

If Not IsNull(Me.[Field C]) And (IsNull(Me.[Field A]) Or IsNull(Me.[Field
B]) ) then
me.[Field C]= Null
End if
 
D

DavidG

Is the data NULL or ZERO LENGTH ?

See http://allenbrowne.com/casu-11.html

Instead of IsNull, I use (for example)
len(Me.[FieldA] & "" ) = 0
This handles both cases.

HTH

DavidG
================================

Ofer said:
On the Got focus event of field C you can write the code

If IsNull(Me.[Field A]) Or IsNull(Me.[Field B]) then
msgbox "Must enter value in fields A and B"
Me.[Field A].SetFocus
End If
=========================
And I assume that you might want some code, to delete the value from field
C
incase the value from fields A and B were deleted

On the After update event of fields a and b, write the code

If Not IsNull(Me.[Field C]) And (IsNull(Me.[Field A]) Or IsNull(Me.[Field
B]) ) then
me.[Field C]= Null
End if
--
If I answered your question, please mark it as an answer. That way, it
will
stay saved for a longer time, so other can benefit from it.

Good luck



Ernie Sersen said:
How do I disable entry of data into form field C unless there is data in
form
fields A and B? Also, is there a way to display a warning box as soon
as
someone places the cursor in or moves the mouse over field C?
 
G

Guest

Data is a date. I have to make sure previous fields have dates entered into
them before entering date into the 'task completed' field. Anyway, the post
helped me out so THANKS!!

DavidG said:
Is the data NULL or ZERO LENGTH ?

See http://allenbrowne.com/casu-11.html

Instead of IsNull, I use (for example)
len(Me.[FieldA] & "" ) = 0
This handles both cases.

HTH

DavidG
================================

Ofer said:
On the Got focus event of field C you can write the code

If IsNull(Me.[Field A]) Or IsNull(Me.[Field B]) then
msgbox "Must enter value in fields A and B"
Me.[Field A].SetFocus
End If
=========================
And I assume that you might want some code, to delete the value from field
C
incase the value from fields A and B were deleted

On the After update event of fields a and b, write the code

If Not IsNull(Me.[Field C]) And (IsNull(Me.[Field A]) Or IsNull(Me.[Field
B]) ) then
me.[Field C]= Null
End if
--
If I answered your question, please mark it as an answer. That way, it
will
stay saved for a longer time, so other can benefit from it.

Good luck



Ernie Sersen said:
How do I disable entry of data into form field C unless there is data in
form
fields A and B? Also, is there a way to display a warning box as soon
as
someone places the cursor in or moves the mouse over field C?
 

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