Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Lockbox works BUT...

Discussion in 'Information Technology' started by lmv, Jul 28, 2006.

Tags:
  1. lmv

    lmv
    Expand Collapse
    Guest

    I have to close my form and reopen it for it to take effect...
    I tried me.refresh and me.requery on current for the form but that doesn't
    help any ideas...?
    Thanks!!

    Form control:
    Private Sub Form_Current()
    Call lockbox_AfterUpdate
    Call AutoFillNewRecord(Forms!OrdersWDetails)

    End Sub
    ------------------------------
    LOCKBOX CONTROLS:

    Private Sub lockbox_AfterUpdate()
    Call LockBoundControls(Me, Me.lockbox.Value, "lockbox")
    End Sub

    Private Sub lockbox_Click()
    Call LockBoundControls(Me, True)
    End Sub
     
  2. Loading...

    Similar Threads Forum Date
    General "Salvation" Through Faith or Works? Hard Talk Jul 16, 2015
    India SGPC To Continue With Diwali Fireworks At Harmandir Sahib Breaking News Oct 27, 2013
    Literature Video: Punjabi scholar translates Shakespeare's entire works into Punjabi Punjab, Punjabi, Punjabiyat May 30, 2013
    Learn Punjabi Why Punjabi is Ignored in Google Networks? Language, Arts & Culture Jan 24, 2013
    Grammer / Vyakarn Sikhbookclub.com has 70% of the Bhai Vir Singh Works available Language, Arts & Culture Jun 14, 2012

  3. Michael H

    Michael H
    Expand Collapse
    Guest

    Hi again.

    Perhaps the reason you have received no replies to this post is that you do
    not clearly state information such as:
    1. What you are trying to accomplish
    2. What problems you are having
    3. What kind of control is "lockbox"
    4. The purpose for, and code behind, the AutoFillNewRecord and
    LockBoundControls procedures

    If you provide the information necessary to solve your problem, you will be
    much more likely to get responses. I suggest you have a look here:
    http://www.mvps.org/access/netiquette.htm#Asking

    -Michael



    "lmv" wrote:

    > I have to close my form and reopen it for it to take effect...
    > I tried me.refresh and me.requery on current for the form but that doesn't
    > help any ideas...?
    > Thanks!!
    >
    > Form control:
    > Private Sub Form_Current()
    > Call lockbox_AfterUpdate
    > Call AutoFillNewRecord(Forms!OrdersWDetails)
    >
    > End Sub
    > ------------------------------
    > LOCKBOX CONTROLS:
    >
    > Private Sub lockbox_AfterUpdate()
    > Call LockBoundControls(Me, Me.lockbox.Value, "lockbox")
    > End Sub
    >
    > Private Sub lockbox_Click()
    > Call LockBoundControls(Me, True)
    > End Sub
     
  4. lmv

    lmv
    Expand Collapse
    Guest

    Sorry if it wasn't clear... here are all of the areas it is being used.

    I have to close and then reopen the form in order for it to work instead of
    it just locking the record and then I should be able to move on but it can
    only be set on 1 record then you have to close. I don't know why.
    -----------
    Private Sub lockbox_AfterUpdate()
    Call LockBoundControls(Me, Me.lockbox.Value, "lockbox")
    End Sub
    -----------------
    Private Sub Form_Current()
    Call LockBoundControls(Me, True)
    'Opens new records with fields filled from last entry
    Call AutoFillNewRecord(Forms!OrdersWDetails)
    Call lockbox_AfterUpdate

    End Sub
    -----------------------
    Private Sub lockbox_Click()
    'fix this can only check one box then have to close the form and reopen
    in order to do another one


    Call LockBoundControls(Me, True)
    'if you want to lock the controls, or:
    'Call LockBoundControls(Me, False)
    'if you want to unlock them


    'If there are controls you *don't* want to lock, add their names as
    extraarguments, e.g.:
    'Call LockBoundControls(Me, True, "Surname", "City")
    End Sub
    ---------------------------
    MODULE:
    Public Function LockBoundControls(frm As Form, bLock As Boolean, ParamArray
    avarExceptionList())
    On Error GoTo Err_Handler
    'Purpose: Lock the bound controls and prevent deletes on the form any
    its subforms.
    'Arguments frm = the form to be locked
    ' bLock = True to lock, False to unlock.
    ' avarExceptionList: Names of the controls NOT to lock
    (variant array of strings).
    'Usage: Call LockBoundControls(Me. True)
    Dim ctl As Control 'Each control on the form
    Dim lngI As Long 'Loop controller.
    Dim bSkip As Boolean

    'Save any edits.
    If frm.Dirty Then
    frm.Dirty = False
    End If
    'Block deletions.
    frm.AllowDeletions = Not bLock

    For Each ctl In frm.Controls
    Select Case ctl.ControlType
    Case acTextBox, acComboBox, acListBox, acOptionGroup, acCheckBox,
    acOptionButton, acToggleButton
    'Lock/unlock these controls if bound to fields.
    bSkip = False
    For lngI = LBound(avarExceptionList) To UBound(avarExceptionList)
    If avarExceptionList(lngI) = ctl.Name Then
    bSkip = True
    Exit For
    End If
    Next
    If Not bSkip Then
    If HasProperty(ctl, "ControlSource") Then
    If Len(ctl.ControlSource) > 0 And Not ctl.ControlSource
    Like "=*" Then
    If ctl.locked <> bLock Then
    ctl.locked = bLock
    End If
    End If
    End If
    End If

    Case acSubform
    'Recursive call to handle all subforms.
    bSkip = False
    For lngI = LBound(avarExceptionList) To UBound(avarExceptionList)
    If avarExceptionList(lngI) = ctl.Name Then
    bSkip = True
    Exit For
    End If
    Next
    If Not bSkip Then
    If Len(Nz(ctl.SourceObject, vbNullString)) > 0 Then
    ctl.Form.AllowDeletions = Not bLock
    ctl.Form.AllowAdditions = Not bLock
    Call LockBoundControls(ctl.Form, bLock)
    End If
    End If

    Case acLabel, acLine, acRectangle, acCommandButton, acTabCtl,
    acPage, acPageBreak, acImage, acObjectFrame
    'Do nothing

    Case Else
    'Includes acBoundObjectFrame, acCustomControl
    Debug.Print ctl.Name & " not handled " & Now()
    End Select
    Next

    'Set the visual indicators on the form.
    On Error Resume Next
    frm.cmdLock.Caption = IIf(bLock, "Un&lock", "&Lock")
    frm!rctLock.Visible = bLock


    Exit_Handler:
    Set ctl = Nothing
    Exit Function

    Err_Handler:
    MsgBox "Error " & err.Number & " - " & err.Description
    Resume Exit_Handler
    End Function

    Public Function HasProperty(obj As Object, strPropName As String) As Boolean
    'Purpose: Return true if the object has the property.
    Dim vardummy As Variant
    On Error Resume Next
    vardummy = obj.Properties(strPropName)
    HasProperty = (err.Number = 0)
    End Function


    "Michael H" wrote:

    > Hi again.
    >
    > Perhaps the reason you have received no replies to this post is that you do
    > not clearly state information such as:
    > 1. What you are trying to accomplish
    > 2. What problems you are having
    > 3. What kind of control is "lockbox"
    > 4. The purpose for, and code behind, the AutoFillNewRecord and
    > LockBoundControls procedures
    >
    > If you provide the information necessary to solve your problem, you will be
    > much more likely to get responses. I suggest you have a look here:
    > http://www.mvps.org/access/netiquette.htm#Asking
    >
    > -Michael
    >
    >
    >
    > "lmv" wrote:
    >
    > > I have to close my form and reopen it for it to take effect...
    > > I tried me.refresh and me.requery on current for the form but that doesn't
    > > help any ideas...?
    > > Thanks!!
    > >
    > > Form control:
    > > Private Sub Form_Current()
    > > Call lockbox_AfterUpdate
    > > Call AutoFillNewRecord(Forms!OrdersWDetails)
    > >
    > > End Sub
    > > ------------------------------
    > > LOCKBOX CONTROLS:
    > >
    > > Private Sub lockbox_AfterUpdate()
    > > Call LockBoundControls(Me, Me.lockbox.Value, "lockbox")
    > > End Sub
    > >
    > > Private Sub lockbox_Click()
    > > Call LockBoundControls(Me, True)
    > > End Sub
     

Share This Page