Lock data access

  • Thread starter eddy via AccessMonster.com
  • Start date
E

eddy via AccessMonster.com

Hi,

I would like to lock data in form from any editing activities.However those
data should be more than a month from "Release Date" . I've tried DateAdd
function On Current Form but its does'nt work.
You quick respond over the matter is most appreciated,

Thank you
 
E

eddy via AccessMonster.com

Sorry, for your reference date format for "Release Date" is dd/mm/yy hh:mm:
ss AM/PM
 
K

Klatuu

Data format is irrelevant. It is carried in the table as a number.
Formatting is only for presentation to humans. You were on the right track,
but, perhaps your syntax is not correct. You don't give enough information
for a complete correct answer, so I will make some assumptions. First is
that Release Date is control on the form and you are comparing a date field
in your recordset to it. Also, if the date in the recordset is more than 30
days prior to Release date, it should not be edited. If it is newer than
that, it can be edited. This will be in the form's Current event.

Dim blnEnableEdits as Boolean

If Me.NewRecord Then
blnEnableEdits
Else
blnEnableEdit = DateDiff("d",Me.txtTableDate, Me.txtReleaseDate) <= 30
End If
Call SetEditControls(blnEnableEdits)

Now, all you need is a sub that takes a boolean argument where true means
enable and false means disable that set the property for the controls you
want.
 
E

eddy via AccessMonster.com

Thanks for the fast reply, accually I just prefer to unenable or locked the
field's form that more a month from current date. I little bit clueless with
boolean data type, please guide me.

Thanks in advance.
Data format is irrelevant. It is carried in the table as a number.
Formatting is only for presentation to humans. You were on the right track,
but, perhaps your syntax is not correct. You don't give enough information
for a complete correct answer, so I will make some assumptions. First is
that Release Date is control on the form and you are comparing a date field
in your recordset to it. Also, if the date in the recordset is more than 30
days prior to Release date, it should not be edited. If it is newer than
that, it can be edited. This will be in the form's Current event.

Dim blnEnableEdits as Boolean

If Me.NewRecord Then
blnEnableEdits
Else
blnEnableEdit = DateDiff("d",Me.txtTableDate, Me.txtReleaseDate) <= 30
End If
Call SetEditControls(blnEnableEdits)

Now, all you need is a sub that takes a boolean argument where true means
enable and false means disable that set the property for the controls you
want.
Sorry, for your reference date format for "Release Date" is dd/mm/yy hh:mm:
ss AM/PM
[quoted text clipped - 7 lines]
 
K

Klatuu

First, I see a problem in my code.

The second line here is incomplete:
It should be
Boolean data type is just Yes/No, usually set by making it True or False
where True = -1 and False = 0. It is an easy way to make a binary decision.

You have never said a month in which direction. Is it one month in the
future or one month in the past? The way the code is written, if
Me.txtTableDate is 30 days or more before Me.txtReleaseDate, bnlEnableEdits
will be set to True, if it is more than 30 days prior to Me.txtReleaseDate,
it will be set to false. The code could be written like this:
blnEnableEdit = DateDiff("d",Me.txtTableDate, Me.txtReleaseDate) <= 30
If DateDiff("d", Me.txtTableDate, Me.txtReleaseDate) <= 30 Then
blnEnableEdits = True
Else
blnEnableEdits = False
End If

Then calling a function with blnEnableEdits as its argument tells the
function which way to set the properties, which are set using True or False.

Hope this helps.

eddy via AccessMonster.com said:
Thanks for the fast reply, accually I just prefer to unenable or locked the
field's form that more a month from current date. I little bit clueless with
boolean data type, please guide me.

Thanks in advance.
Data format is irrelevant. It is carried in the table as a number.
Formatting is only for presentation to humans. You were on the right track,
but, perhaps your syntax is not correct. You don't give enough information
for a complete correct answer, so I will make some assumptions. First is
that Release Date is control on the form and you are comparing a date field
in your recordset to it. Also, if the date in the recordset is more than 30
days prior to Release date, it should not be edited. If it is newer than
that, it can be edited. This will be in the form's Current event.

Dim blnEnableEdits as Boolean

If Me.NewRecord Then
blnEnableEdits
Else
blnEnableEdit = DateDiff("d",Me.txtTableDate, Me.txtReleaseDate) <= 30
End If
Call SetEditControls(blnEnableEdits)

Now, all you need is a sub that takes a boolean argument where true means
enable and false means disable that set the property for the controls you
want.
Sorry, for your reference date format for "Release Date" is dd/mm/yy hh:mm:
ss AM/PM
[quoted text clipped - 7 lines]
Thank you
 
Top