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!