Making a date field "Locked Out" if another Date Field is Null

G

Guest

Greetings folks! :)

I have two date fields within my form. One is named "TopicYearStarted" and
the other is named "TopicYearReleased". I would like to fix it where if the
"TopicYearStarted" isn't filled out then the "TopicYearReleased" isn't
accessable (or locked or not enabled).

Can someone help me out with this? These codes confuse me. :) Thank you
so much for your time and help!! :)

Wayne
 
A

Allen Browne

Use the AfterUpdate event procedure of TopicYearStarted to set the Enabled
property of TopicYearReleased.

Then in the Current event procedure of the form:
Call TopicYearStarted_AfterUpdate

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 
G

Guest

Hey Allen!

Thanks for the reply.

Okay, I know what you mean when you said "Set the Enabled Property of
TopicYearReleased", but I don't fully understand what you mean by "Call"
TopicYearStarted_AfterUpdate. Is that the code I would use?

I apologize for these questions! But I am learning! :)

Wayne
 
J

John Vinson

Greetings folks! :)

I have two date fields within my form. One is named "TopicYearStarted" and
the other is named "TopicYearReleased". I would like to fix it where if the
"TopicYearStarted" isn't filled out then the "TopicYearReleased" isn't
accessable (or locked or not enabled).

Can someone help me out with this? These codes confuse me. :) Thank you
so much for your time and help!! :)

Wayne

You'll need to put some VBA code in two places: in the form's Current
event to enable or disable the control when you move to a new record,
and in the AfterUpdate event of TopicYearStarted. Something like:

Private Sub Form_Current()
If IsNull(Me!TopicYearStarted) Then
Me!TopicYearReleased.Enabled = False
Else
Me!TopicYearReleased.Enabled = True
End If
End Sub

or, more elegantly if less readably:

Private Sub Form_Current()
Me!TopicYearReleased.Enabled = Not IsNull(Me!TopicYearStarted)
End Sub

Put the same code in the AfterUpdate event of TopicYearStarted to
toggle the Released control when you change the Started one.

John W. Vinson[MVP]
 
G

Guest

Thanks! The two of you! I understand now. I just keep forgetting that you
have to be all logical with it all. It's basic but sometimes even the basic
information will confuse me.

Again, thanks for your help! :)

Wayne
 

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