Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2011
    Posts
    13

    Unanswered: Locking old records

    Is their any way to lock old records and make them grey? I set the AllowEdit option to False but it doesnt let me enter new records.
    Actually I have a transaction list in which user enters data. I want to lock the transaction once it has been posted so no one can make any changes in them. But user should be able to post new transactions.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    you need to identify how you 'know' what are old records. then place some code behind the form which determines if a user can change data

    several ways to do it
    one is in the forms on current event (the event that fires when a record is first dispalyed) and set the allow edits property of the form as required. whether thats a good solution I dunno. I don't know how access handles changes to the allow edits once a form is laoded

    another approach is to set each control allow edits
    or set the on mouse donw event to reject any keyboard input

    bear in mind if you do change the behaviour then you need to set it both wyas

    eg psuedocode
    if (sealedrecord) then
    ( mycontrol01.allowedits = false
    mycontrolnn.allowedits = false
    ) else
    ( mycontrol01.allowedits = true
    mycontrolnn.allowedits = true
    )


    or psuedocode
    if (sealedrecord) then
    ( editflag = false
    ) else
    ( editflag = true
    )
    mycontrol01.allowedits = editflag
    mycontrolnn.allowedits = editflag
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2011
    Posts
    13
    yeah i want as soon as the transaction is entered it gets locked. Ironicalli I dont know VB! i have been given a database to support. Can you kindly elaborate... i mean exactly what code i need to run and where?
    Thanks.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    try experimenting
    the psuedo code is near enough
    replace the (sealedrecord) with a boolean expression which identifies if a record needs to be locked (ie non editable)

    as to where you place your code thats up to you
    read up on the allow edits property on the form, and or the keydown event of each control
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Cool

    Quote Originally Posted by A Abbas View Post
    yeah i want as soon as the transaction is entered it gets locked. Ironicalli I dont know VB! i have been given a database to support. Can you kindly elaborate... i mean exactly what code i need to run and where?
    Thanks.
    Hi,
    Elaborating.....

    Code:
    Private Sub Form_Current()
    
        Me.AllowEdits = False   'Return the form to its ReadOnly state.
        OrgNameLookup = OrganizationID 'Update the OrgNameLookup combo box.
        FirstName.SetFocus
        
    End Sub
    Next is this:

    Code:
    Private Sub Form_AfterUpdate()
    
        Me.AllowEdits = False  'Return the form to its ReadOnly state.
        
    End Sub
    Also this:

    Code:
    Private Sub Form_Open(Cancel As Integer)
        
        DoCmd.Requery
        Refresh
        
    End Sub
    Create a CommandButton and place this behind it in case you need to edit a now locked record...it happens

    Code:
    Private Sub cmdEditRecord_Click()
    
        Me.AllowEdits = True    'Makes the form temporarily Editable.
        Me.cEmail.Enabled = True
        Me.Email.Enabled = True
        Me.Web.Enabled = True
        FirstName.SetFocus
        
        Me.lblEditMode.Visible = True
        
        
    End Sub
    Create a CommandButton and place this behind it....name it SAVED or whatever you like.

    Code:
    Private Sub cmdSaveRecord_Click()
    On Error GoTo Err_cmdSaveRecord_Click
    
    
        DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
        Me.FirstName.SetFocus
        'Me.cEmail.Enabled = False
        'Me.Email.Enabled = False
        'Me.Web.Enabled = False
        MsgBox "Record is now saved.", vbOKOnly, "Record Saved"
        Me.AllowEdits = False
        
        Me.lblEditMode.Visible = False
    
    Exit_cmdSaveRecord_Click:
        Exit Sub
    
    Err_cmdSaveRecord_Click:
        MsgBox "You haven't added or changed anything to save." 'Err.Description
        Resume Exit_cmdSaveRecord_Click
        
    End Sub
    This saves the record and refreshes it and sets it back to a locked state. You can do the Gray thing any way you choose. But the way I think you were doing it was actually setting it to LOCKED. Whatever flavor is the best tasting. Anyhow, this is yours.

    All this is taken from one of my old database forms that I did a few years back. I did learn that from being in this particular forum. They DO help you................to LEARN HOW TO DO IT. Just be patient and listen to them and try all that is suggested.

    Have a nice one,
    Bud

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •