Code to enabld/disable buttons in form based on information in table

N

newtoaccessdb

Ok, I hope I am posting in the right group now...
I am very new to code, and need to make a form uneditable to users who

are not the author of the record, as well as make uneditable to anyone
once a "completed" button is pushed which sets the date into a table.
Any help would be greatly appreciated.

Access 03 /Win XP

I have the database almost completed except for this one last issue.
 
M

Marshall Barton

newtoaccessdb said:
I am very new to code, and need to make a form uneditable to users who
are not the author of the record, as well as make uneditable to anyone
once a "completed" button is pushed which sets the date into a table.
Any help would be greatly appreciated.

Access 03 /Win XP

I have the database almost completed except for this one last issue.


You need a way to identify the current user so you can
compare to the author.

The completed issue can be checked in the form's Current
event:
If IsNull(Me.CompletedDate) Then
'make form or controls editable
Else
'lock the form or controls
End If

Depending on if your form controls are all bound to fields
in the fprm's record source table/query or if some controls
are unbound controls used for searching/navigation.

If there are no unbound controls, you can just use the
form's AllowEdits property:
Me.AllowEdits = True/False

If some controls need to remain unlocked, then set the Tag
property of the controls that should be locked to something
indicative such as LOCK. This allows you to use a loop to
lock/unlock the bound controls:

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "LOCK" Then
ctl.Locked = True/False
End If
Next ctl
 

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