Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2008

Tip: Looking for answers? Try searching our database.

Lock two fields?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith - 12 Mar 2008 02:35 GMT
I have a form, that a couple people use. Can I take the below and lock two
fields instead of 1? The two fields would not always have data in them at the
same time. One person opens the form, does their work, then another person
does their work and closes it, I want to be able to lock those fields so the
next time it opens those two fields are locked.

Would I just duplicate the same code and have 2 on current events?

Private Sub Form_Current()
 If Not IsNull(Me.DueDate) Then
   DueDate.Locked = True
 Else
   DueDate.Locked = False
End If
End Sub
Linq Adams - 12 Mar 2008 03:43 GMT
NO! You can only have one of any given event in a form! Just put both sets of
code in your On Current event.

Private Sub Form_Current()
If Not IsNull(Me.DueDate) Then
  DueDate.Locked = True
 Else
   DueDate.Locked = False
End If

If Not IsNull(Me.OtherField) Then
  OtherField.Locked = True
 Else
   OtherField.Locked = False
End If
End Sub

Signature

There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Beetle - 12 Mar 2008 03:52 GMT
You can lock as many controls as you want in an event;

Private Sub Form_Current()
  If Not IsNull(Me.DueDate) Then
    DueDate.Locked = True
    Contol2.Locked = True
  Else
    DueDate.Locked = False
    Control2.Locked = False
End If
End Sub

You just need to make sure you have some method by which to unlock them
if they ever need to be edited

Signature

_________

Sean Bailey

> I have a form, that a couple people use. Can I take the below and lock two
> fields instead of 1? The two fields would not always have data in them at the
[quoted text clipped - 11 lines]
> End If
> End Sub
Keith - 12 Mar 2008 04:18 GMT
You all are so awesome! Thank you! Wish I could buy you all some beers!!!

> You can lock as many controls as you want in an event;
>
[quoted text clipped - 26 lines]
> > End If
> > End Sub
Keith - 12 Mar 2008 04:34 GMT
I guess what I need is:
I have 2 checkboxes that time stamp a field. One group opens the form, does
their work and then closes it. Then another group has their own checkbox that
timestamps. So, can I lock the timestamps after each group?
Does this make sense?

Thanks,
Keith

> You can lock as many controls as you want in an event;
>
[quoted text clipped - 26 lines]
> > End If
> > End Sub
Beetle - 12 Mar 2008 04:58 GMT
So you have two text boxes, each of which is time stamped
programmatically when the check box is clicked? If that is the
case then you can just set the text boxes to locked = Yes in the
properties (no code needed). Having a control locked does not
prevent you from changing it's value via code

Or do the users have to manually enter the time?
Signature

_________

Sean Bailey

> I guess what I need is:
> I have 2 checkboxes that time stamp a field. One group opens the form, does
[quoted text clipped - 35 lines]
> > > End If
> > > End Sub
Keith - 12 Mar 2008 05:13 GMT
Yes, when they check the checkbox it time stamps a field.
Then another group goes in and checks their box and it time stamps another
field.
So, two groups will open the same form, after each group closes it, I want
to lock that groups field. Hopefully that makes more sense.

> So you have two text boxes, each of which is time stamped
> programmatically when the check box is clicked? If that is the
[quoted text clipped - 43 lines]
> > > > End If
> > > > End Sub
Beetle - 12 Mar 2008 05:20 GMT
What event/code are you currently using to create the timestamp?
Signature

_________

Sean Bailey

> Yes, when they check the checkbox it time stamps a field.
> Then another group goes in and checks their box and it time stamps another
[quoted text clipped - 49 lines]
> > > > > End If
> > > > > End Sub
Beetle - 12 Mar 2008 05:04 GMT
I just reread your post and realized I may have misunderstood you. Are
you only timestamping the underlying field in the table (no text boxes
that display the timestamp value on the form)?

And are you trying to prevent the value from being overwritten if
the checkbox is clicked again?
Signature

_________

Sean Bailey

> I guess what I need is:
> I have 2 checkboxes that time stamp a field. One group opens the form, does
[quoted text clipped - 35 lines]
> > > End If
> > > End Sub
Keith - 12 Mar 2008 05:20 GMT
Yes, the text boxes (timestamps) are displayed but are locked.

Yes, that is exactly what I'm trying to do. I don't want the value
(timestamp) to be overwritten once it's clicked or they exit the form and go
back in.

Thank you for all your help,
Keith

> I just reread your post and realized I may have misunderstood you. Are
> you only timestamping the underlying field in the table (no text boxes
[quoted text clipped - 42 lines]
> > > > End If
> > > > End Sub
Beetle - 12 Mar 2008 06:08 GMT
Here is one example of code that could be used in the After Update
event of the checkbox;

Private Sub checkbox_AfterUpdate

If Me.checkbox = True Then
  If IsNull(Me.DueDate) Then
      Me.DueDate = DateAdd("d", 30, Date())
 End If
End If

End Sub

The above code would set the due date to 30 days from today.

First, this code would only run if the checkbox was being changed
from False to True (unchecked to checked) otherwise it would do nothing.

Second, the code would only run if the Due Date was null. If there was
already a value there, it would do nothing.

As long as the text boxes were locked (which I would do in the properties
for each text box), then the time stamp could not be overwritten (at least
not without doing it directly in the table)

Signature

_________

Sean Bailey

> Yes, the text boxes (timestamps) are displayed but are locked.
>
[quoted text clipped - 51 lines]
> > > > > End If
> > > > > End Sub
Keith - 13 Mar 2008 00:39 GMT
Ah, that would work. Thank you, that will be perfect!

Thanks for all your help!!!

> Here is one example of code that could be used in the After Update
> event of the checkbox;
[quoted text clipped - 76 lines]
> > > > > > End If
> > > > > > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.