Minggu, 12 Mei 2013

RE: [MS_AccessPros] How to lock record if status is completed

 

Kumar-

It can be a Sub in the form's code module. You should have code in your
Current event to determine the status of the current record, then call
LockIt accordingly. Perhaps something like:

Private Sub Form_Current()
' If the current record is complete,
If Me.Status = "Complete" Then
' Call procedure to lock all controls
LockIt True
Else
' Not complete - unlock everything
LockIt False
End If

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of access_kri
Sent: Sunday, May 12, 2013 7:02 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] How to lock record if status is completed

John-
I am not getting you. Where should I put this routine lockit? I believe
Department is a field in the record. What I want to achieve is that when I
open the form, the records that have status marked as "complete" should be
non-editable and only those records that have intermediate statuses should
be editable.

Request you to guide me further.

Kind Regards,
Kumar

--- In MS_Access_Professionals@yahoogroups.com, John Viescas <JohnV@...>
wrote:
>
> Kumar-
>
> Locking individual controls is the most flexible method, but you can
> make it simpler by writing a routine like this:
>
> Private Sub Lockit(intLocked As Integer) Dim ctl As control
> On Error Resume Next
>
> ' Move the focus to a control that won't be affected
> Me.txtSafe.SetFocus
>
> ' Set Locked for all text boxes, combo boxes, check boxes, and
subforms
> ' in Detail section based on paramter
> For Each ctl In Me.Section(0).Controls
> Select Case ctl.ControlType
> Case acTextBox, acComboBox, acCheckBox, acSubform
> ctl.Locked = intLocked
> Case acCommandButton
> ctl.Enabled = Not (intLocked)
> End Select
> Next ctl
>
> ' Put the focus back
> Me.Department.SetFocus
>
> End Sub
>
> In the above example, txtSafe is a tiny text box that's not in the tab
> order hidden on one corner. The code puts the focus there to be sure
> it can change the locked status of all controls - you can't changed
> Locked if the control has the focus. Section(0) is the Detail section
> of the form. I'm also handling command buttons in this example
> because I had a custom command button that called a custom date/time
> input form next to all date/time fields. I needed to disable those
> command buttons when the record shouldn't be edited.
>
> You can also set Me.AllowEdits = False to disable all editing in one
> step, but that locks all controls including command buttons and
> unbound combo or list boxes.
>
> John Viescas, Author
> Microsoft Access 2010 Inside Out
> Microsoft Access 2007 Inside Out
> Microsoft Access 2003 Inside Out
> Building Microsoft Access Applications SQL Queries for Mere Mortals
> http://www.viescas.com/ (Paris, France)
>
>
>
>
> -----Original Message-----
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of
> access_kri
> Sent: Saturday, May 11, 2013 12:36 PM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: [MS_AccessPros] How to lock record if status is completed
>
> Dear All,
> How can I make records that have completed status locked
> (uneditable) and editable if the records have status other than
> complete. At present, I am locking all the textboxes and comboboxes
> individual in the forms Oncurrent property. How can I reference the
> entire record instead of individual objects? Thanks
>
> Kind Regards,
> Kumar
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>

------------------------------------

Yahoo! Groups Links

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar