Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Locking Records on print (2003 SP3)

    What is a good way to lock a record? I would like to lock a record as soon as an order is printed, yet make it easy to unlock with a hidden checkbox or something like that.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Locking Records on print (2003 SP3)

    You cannot really lock records in a table, and you don't really know whether records have actually been printed, but you could do something like this:
    - Add a Yes/No field Printed to the table.
    - Create a form based on the table (or use an existing form based on the table).
    - Put a command button on the form that opens a report.
    - Add code that sets the Printed field to True for records displayed in the report.
    - Use code like this in the On Current event of the form:

    Private Sub Form_Current()
    Me.AllowEdits = Not Me.Printed
    End Sub

    - You can use a "management" form to reset the Printed field to False for specific records.

  3. #3
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Locking Records on print (2003 SP3)

    OK, this is the code I have for printing an order.

    Private Sub PrChecklist_Click()
    On Error GoTo Err_PrChecklist_Click
    Me.Refresh
    Dim stDocName As String

    stDocName = "rptOrderChecklist"
    DoCmd.OpenReport stDocName, acWindowNormal, , "OrderID=" & Me.OrderID
    Me.chkLocked = True
    If Me.FilterOn = True Then
    Me.FilterOn = False
    End If
    DoCmd.GoToRecord , "frmOrders", acNewRec
    DoCmd.GoToControl "cboCustomerID"
    Me.txtDefaultQty = 1

    Exit_PrChecklist_Click:
    Exit Sub

    Err_PrChecklist_Click:
    MsgBox Err.Description
    Resume Exit_PrChecklist_Click

    End Sub


    Is it possible to integrate it into this code? I think I follow your advice but wonder if it is possible to integrate it into this code. I just added the chkLocked a little bit ago. I had put an unbound checkbox on my form.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Locking Records on print (2003 SP3)

    You can use the code you have without modifications, but you'll have to do the following in addition:
    - Create a Yes/No field in the table and set the control source of chkLocked to the name of the Yes/No field.
    - Add the following line to the On Current event procedure for the form:

    Me.AllowEdits = Not Me.chkLocked

  5. #5
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Locking Records on print (2003 SP3)

    Ran into a snag. I have the default value set to FALSE in the table. Is that messing it up?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Locking Records on print (2003 SP3)

    A Yes/No field is never Null. Your screenshot shows that chkPrinted is Null, this makes me suspect that it is still an unbound control. It should be bound to the Yes/No field.

Posting Permissions

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