Field only sometimes required & uncheck event

G

Guest

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
 
G

Guest

Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

freakazeud said:
Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

freakazeud said:
Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

Okay....I used the first part of your suggestion which works fine but I'm
having trouble with the second part. Your suggestion doesn't seem to do
anything. I tried using a Validation Rule which for some reason works if you
enter info and delete it so there is a blank but it doesn't work if you just
tab through leaving blanks from the start.
Thanks
Kristine
freakazeud said:
Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

freakazeud said:
Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

hi,
why is the second solution not working?
Did you put the code on the before update event. Did you change the name of
the control to the name of your second control?
You don't need to use a validation rule. Use VBA code. There are many other
solutions which should work.
HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Okay....I used the first part of your suggestion which works fine but I'm
having trouble with the second part. Your suggestion doesn't seem to do
anything. I tried using a Validation Rule which for some reason works if you
enter info and delete it so there is a blank but it doesn't work if you just
tab through leaving blanks from the start.
Thanks
Kristine
freakazeud said:
Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

:

Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

I don't know why it's not working. I tried again to double check but it still
isn't working. If I do not enter the data when filling out the form it just
goes to the next tab stop. Can you tell what's wrong?

Private Sub RX_1_Strength_BeforeUpdate(Cancel As Integer)
If Me.RX_1_Strength = "" Then
Cancel = True
MsgBox ("Please enter Drug 1 Strength")
End If

End Sub

What does the 'Cancel = True' relate to?


freakazeud said:
hi,
why is the second solution not working?
Did you put the code on the before update event. Did you change the name of
the control to the name of your second control?
You don't need to use a validation rule. Use VBA code. There are many other
solutions which should work.
HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Okay....I used the first part of your suggestion which works fine but I'm
having trouble with the second part. Your suggestion doesn't seem to do
anything. I tried using a Validation Rule which for some reason works if you
enter info and delete it so there is a blank but it doesn't work if you just
tab through leaving blanks from the start.
Thanks
Kristine
freakazeud said:
Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

:

Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

hi,
cancel = true is a variable in the before update event which does not allow
you to step out of the control unless a validation is correctly validated.
I'm assuming that your control is NULL which is different then "" which is
an empty string. You have to check for BOTH:

If IsNull(Me.YourControl) Or Me.YourControl = "" Then...

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
I don't know why it's not working. I tried again to double check but it still
isn't working. If I do not enter the data when filling out the form it just
goes to the next tab stop. Can you tell what's wrong?

Private Sub RX_1_Strength_BeforeUpdate(Cancel As Integer)
If Me.RX_1_Strength = "" Then
Cancel = True
MsgBox ("Please enter Drug 1 Strength")
End If

End Sub

What does the 'Cancel = True' relate to?


freakazeud said:
hi,
why is the second solution not working?
Did you put the code on the before update event. Did you change the name of
the control to the name of your second control?
You don't need to use a validation rule. Use VBA code. There are many other
solutions which should work.
HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Okay....I used the first part of your suggestion which works fine but I'm
having trouble with the second part. Your suggestion doesn't seem to do
anything. I tried using a Validation Rule which for some reason works if you
enter info and delete it so there is a blank but it doesn't work if you just
tab through leaving blanks from the start.
Thanks
Kristine
:

Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

:

Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

Sorry!!! I thought I did not need both the 'IsNull' and '<>""'. Doh! I added
it and it works beautifully! Thanks for your help!

Kristine

freakazeud said:
hi,
why is the second solution not working?
Did you put the code on the before update event. Did you change the name of
the control to the name of your second control?
You don't need to use a validation rule. Use VBA code. There are many other
solutions which should work.
HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Okay....I used the first part of your suggestion which works fine but I'm
having trouble with the second part. Your suggestion doesn't seem to do
anything. I tried using a Validation Rule which for some reason works if you
enter info and delete it so there is a blank but it doesn't work if you just
tab through leaving blanks from the start.
Thanks
Kristine
freakazeud said:
Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

:

Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

You're welcome :)
Glad I could assist!
Good luck on future projects!
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Sorry!!! I thought I did not need both the 'IsNull' and '<>""'. Doh! I added
it and it works beautifully! Thanks for your help!

Kristine

freakazeud said:
hi,
why is the second solution not working?
Did you put the code on the before update event. Did you change the name of
the control to the name of your second control?
You don't need to use a validation rule. Use VBA code. There are many other
solutions which should work.
HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Okay....I used the first part of your suggestion which works fine but I'm
having trouble with the second part. Your suggestion doesn't seem to do
anything. I tried using a Validation Rule which for some reason works if you
enter info and delete it so there is a blank but it doesn't work if you just
tab through leaving blanks from the start.
Thanks
Kristine
:

Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

:

Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

Scratch that. I swear it worked but now it's not. It still only works after
data is entered and deleted.

Private Sub RX_1_Amount_BeforeUpdate(Cancel As Integer)
If IsNull(Me.RX_1_Amount) Or Me.RX_1_Amount = "" Then
Cancel = True
MsgBox ("Please enter Drug 1 Amount")
End Sub

I must have tweeked something but I can't tell what. Any ideas?



smilee8_28 said:
Sorry!!! I thought I did not need both the 'IsNull' and '<>""'. Doh! I added
it and it works beautifully! Thanks for your help!

Kristine

freakazeud said:
hi,
why is the second solution not working?
Did you put the code on the before update event. Did you change the name of
the control to the name of your second control?
You don't need to use a validation rule. Use VBA code. There are many other
solutions which should work.
HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Okay....I used the first part of your suggestion which works fine but I'm
having trouble with the second part. Your suggestion doesn't seem to do
anything. I tried using a Validation Rule which for some reason works if you
enter info and delete it so there is a blank but it doesn't work if you just
tab through leaving blanks from the start.
Thanks
Kristine
:

Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

:

Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

Try:

If Len(Me.YourControl & vbNullString) = 0 Then
....

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Scratch that. I swear it worked but now it's not. It still only works after
data is entered and deleted.

Private Sub RX_1_Amount_BeforeUpdate(Cancel As Integer)
If IsNull(Me.RX_1_Amount) Or Me.RX_1_Amount = "" Then
Cancel = True
MsgBox ("Please enter Drug 1 Amount")
End Sub

I must have tweeked something but I can't tell what. Any ideas?



smilee8_28 said:
Sorry!!! I thought I did not need both the 'IsNull' and '<>""'. Doh! I added
it and it works beautifully! Thanks for your help!

Kristine

freakazeud said:
hi,
why is the second solution not working?
Did you put the code on the before update event. Did you change the name of
the control to the name of your second control?
You don't need to use a validation rule. Use VBA code. There are many other
solutions which should work.
HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Okay....I used the first part of your suggestion which works fine but I'm
having trouble with the second part. Your suggestion doesn't seem to do
anything. I tried using a Validation Rule which for some reason works if you
enter info and delete it so there is a blank but it doesn't work if you just
tab through leaving blanks from the start.
Thanks
Kristine
:

Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

:

Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

Bummers. Still no.

freakazeud said:
Try:

If Len(Me.YourControl & vbNullString) = 0 Then
...

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Scratch that. I swear it worked but now it's not. It still only works after
data is entered and deleted.

Private Sub RX_1_Amount_BeforeUpdate(Cancel As Integer)
If IsNull(Me.RX_1_Amount) Or Me.RX_1_Amount = "" Then
Cancel = True
MsgBox ("Please enter Drug 1 Amount")
End Sub

I must have tweeked something but I can't tell what. Any ideas?



smilee8_28 said:
Sorry!!! I thought I did not need both the 'IsNull' and '<>""'. Doh! I added
it and it works beautifully! Thanks for your help!

Kristine

:

hi,
why is the second solution not working?
Did you put the code on the before update event. Did you change the name of
the control to the name of your second control?
You don't need to use a validation rule. Use VBA code. There are many other
solutions which should work.
HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Okay....I used the first part of your suggestion which works fine but I'm
having trouble with the second part. Your suggestion doesn't seem to do
anything. I tried using a Validation Rule which for some reason works if you
enter info and delete it so there is a blank but it doesn't work if you just
tab through leaving blanks from the start.
Thanks
Kristine
:

Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

:

Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

Hi,
try to use the control's on exit event:

If Len(Me.Text2 & vbNullString) = 0 Then
MsgBox ("na na na")
Me.Text2.SetFocus
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Bummers. Still no.

freakazeud said:
Try:

If Len(Me.YourControl & vbNullString) = 0 Then
...

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Scratch that. I swear it worked but now it's not. It still only works after
data is entered and deleted.

Private Sub RX_1_Amount_BeforeUpdate(Cancel As Integer)
If IsNull(Me.RX_1_Amount) Or Me.RX_1_Amount = "" Then
Cancel = True
MsgBox ("Please enter Drug 1 Amount")
End Sub

I must have tweeked something but I can't tell what. Any ideas?



:

Sorry!!! I thought I did not need both the 'IsNull' and '<>""'. Doh! I added
it and it works beautifully! Thanks for your help!

Kristine

:

hi,
why is the second solution not working?
Did you put the code on the before update event. Did you change the name of
the control to the name of your second control?
You don't need to use a validation rule. Use VBA code. There are many other
solutions which should work.
HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Okay....I used the first part of your suggestion which works fine but I'm
having trouble with the second part. Your suggestion doesn't seem to do
anything. I tried using a Validation Rule which for some reason works if you
enter info and delete it so there is a blank but it doesn't work if you just
tab through leaving blanks from the start.
Thanks
Kristine
:

Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

:

Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 
G

Guest

That's it! You're fabulous!

freakazeud said:
Hi,
try to use the control's on exit event:

If Len(Me.Text2 & vbNullString) = 0 Then
MsgBox ("na na na")
Me.Text2.SetFocus
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


smilee8_28 said:
Bummers. Still no.

freakazeud said:
Try:

If Len(Me.YourControl & vbNullString) = 0 Then
...

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Scratch that. I swear it worked but now it's not. It still only works after
data is entered and deleted.

Private Sub RX_1_Amount_BeforeUpdate(Cancel As Integer)
If IsNull(Me.RX_1_Amount) Or Me.RX_1_Amount = "" Then
Cancel = True
MsgBox ("Please enter Drug 1 Amount")
End Sub

I must have tweeked something but I can't tell what. Any ideas?



:

Sorry!!! I thought I did not need both the 'IsNull' and '<>""'. Doh! I added
it and it works beautifully! Thanks for your help!

Kristine

:

hi,
why is the second solution not working?
Did you put the code on the before update event. Did you change the name of
the control to the name of your second control?
You don't need to use a validation rule. Use VBA code. There are many other
solutions which should work.
HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Okay....I used the first part of your suggestion which works fine but I'm
having trouble with the second part. Your suggestion doesn't seem to do
anything. I tried using a Validation Rule which for some reason works if you
enter info and delete it so there is a blank but it doesn't work if you just
tab through leaving blanks from the start.
Thanks
Kristine
:

Hi,
you can do the validation on the form level.
On the after update event of the one control you can set focus to the other
control which is required if data was entered:

If Not IsNull(Me.YourControl01) Or Me.YourControl <> "" Then
Me.YourControl02.SetFocus
End If

Then on the before update event of the second control do validation again:

If IsNull(Me.YourControl02) Or Me.YourControl02 = "" Then
Cancel = True
MsgBox("Need value here!")
End If

HTH
Good luck

--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Great! That worked! Thanks!

Now I just need help with the first question.
Thanks again!

:

Hi,
try on the after update event of the checkbox:

If Me.Checkbox.Value = True Then
Me.CompletionDate.Value = Now()
Else
Me.CompletionDate.Value = Null
End If

HTH
Good luck
--
Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Two questions:

- How do I make data required only if other data is entered. I only need
information regarding a prescription refill if the drug name is entered. If
the drug name is entered, the strength and quantity fields must also be
entered.

- I have a checkbox that when clicked enters the current date and time in
another field but I can't figure out how to clear the other field if the box
is clicked again. It just updates the date and time whether the checkbox is
being checked or unchecked. I tried =Iif([checkbox]=No, [Completion
Date]="",[Completion Date]=Now()). It didn't work. I tried it as an OnClick
and AfterUpdate event with no luck.

Thanks so much for your help!
 

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