Locking Field based on date

I

ItsBarbara

In attempting to lock fields after a specified date, I am using a solution
proposed by Klatuu that seemed to work:

Dim dtmCutOff30 As Date
Dim dtmCutOff33 As Date
Dim dtmCutOff36 As Date

dtmCutOff30 = DateSerial(Year(date), 4, 3)
dtmCutOff33 = DateSerial(Year(date), 4, 24)
dtmCutOff36 = DateSerial(Year(date), 5, 15)
Me.Week30.Locked = Date() > dtmCutOff30
Me.Week33.Locked = Date() > dtmCutOff33
Me.Week36.Locked = Date() > dtmCutOff36

When I try to open the form, I am getting the following error:

Compile Error:
Method or data member not found

and the .Locked= following Me.Week30 is highlighted.

Also, it changed the Date() to Date

I
What am I doing wrong??

Background: Teachers are entering scores during Week 30. These scores need
to be locked so that they cannot be changed after a specific date....

Then they will enter scores again during Week 33. These too, must be locked
after the specified date.

Same for week 36
 
T

tina

try

Me.Week30.Locked = (Date > dtmCutOff30)

if it works, change the syntax of the other two lines of code, as well.

hth
 
I

ItsBarbara

It still isn't working. I copied code that was in error and noted what was
highlighted below:


Private Sub Form_Open(Cancel As Integer) Highlighted in yellow -
entire line
Dim dtmCutOff30 As Date
Dim dtmCutOff33 As Date
Dim dtmCutOff36 As Date
dtmCutOff30 = DateSerial(Year(Date), 4, 3)
dtmCutOff33 = DateSerial(Year(Date), 4, 24)
dtmCutOff36 = DateSerial(Year(Date), 5, 15)
Me.Week30.Locked = (Date > dtmCutOff30) Highlighted in blue - .Locked
Me.Week33.Locked = (Date > dtmCutOff33)
 
T

tina

if i understand you, the following line

Private Sub Form_Open(Cancel As Integer)

was highlighted in yellow, correct? try this: open the form in design view,
and go to the module window. on the menu bar, select Debug | Compile. look
at what line is highlighted (if any), and what the message box says; post
that information back here.

hth
 
I

ItsBarbara

I did that.
Only this: ".Locked" (minus the " of course)
in the line
Me.Week30.Locked = (Date > dtmCutOff30)
is what is highlightd

Message says
Compile error:
Method or data member not found
 
T

tina

okay. sounds like Access is trying to tell you that the Locked property is
not availabe to Week30. what *is* the object named Week30? is it a *control*
in the form? if so, what kind of control is it?

hth
 
I

ItsBarbara

Week 30 is a text box referencing the field titled Week30 into which teachers
enter a numeric grade. Currently, I lock this manually after the deadline for
30 week grades has passed. I was looking for a way to lock it auomatically
after a certain date.
 
T

tina

yes, i understood what you're trying to accomplish. it's a common sort of
task in a form, and the code *should* work fine. double check that the
*name* of the control which is bound to the Week30 field, is actually also
"Week30" - with no difference in spelling, spacing, etc. if it is, then
there's something else going on that we can't see. in that case, i'm willing
to take a look at your db and see if i can spot the problem. if you want me
to do that - and assuming that the control name is not the problem - then
post back and i'll tell you how to email a copy of the db to me.

hth
 

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