On my form I have a button [LOCKRECORD] that is being used to lock a persons file.
When the button if pressed TWO things must occur –
(1) the program checks to see if the record is already locked – if it is then the user is given a message that the record is already locked.
(2) If the record is not locked then – then the system must verify with the user that they want to indeed lock the record using an input from the message box.
I was able to get the form to lock initially however – because I am looking for two things – if the record is unlocked it will show the message box BUT if I select CANCEL – it still locks the record.
Here is the code:
Private Sub btnLockFile_Click()
If cboRecordLock = True Then
MsgBox "This Record is Already Locked " & vbCrLf & _
"and Can Not Be Unlocked or Altered", vbExclamation
Else
Dim cboInput As Boolean
Dim booLocked As Boolean
intResponse = MsgBox("You are About to Permanently Lock " & _
"This Record. If You Proceed," & vbCrLf & _
"This Record Will Be Disabled and Can Not Be " & vbCrLf & _
"Edited or Altered. To Continue Press YES" & vbCrLf & _
"or Press NO or CANCEL to Dismiss This Action", _
vbOKCancel + vbQuestion + vbDefaultButton1, _
"Critical Information")
cboInput = intResponse
If cboInput = 1 Then
cboRecordLock = cboInput
txtDateLocked = Date
txtLockBy = CurrentUser()
imgLock.Visible = True
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
booLocked = True
cboRecordLock.Locked = booLocked
txtDateLocked.Locked = booLocked
txtLockBy.Locked = booLocked
Me.txtFirst.Locked = booLocked
Me.txtLast.Locked = booLocked
Me.txtMaiden.Locked = booLocked
Me.txtPrefix.Locked = booLocked
Me.txtAddress.Locked = booLocked
Me.txtCity.Locked = booLocked
Me.txtState.Locked = booLocked
Me.txtZip.Locked = booLocked
Me.txtCountry.Locked = booLocked
Me.txtHomePhone.Locked = booLocked
Me.txtWorkPhone.Locked = booLocked
Me.txtEmail.Locked = booLocked
Me.subformCampExperiences.Locked = booLocked
Me.subformDPCampExperience.Locked = booLocked
Me.subformSovietExperience.Locked = booLocked
Me.subformRescuerExperience.Locked = booLocked
Me.SubFormLiberators.Locked = booLocked
Me.subformPOW.Locked = booLocked
Me.SubfrmResistance.Locked = booLocked
Me.subformHiding.Locked = booLocked
Me.SubFormPartisanExperience.Locked = booLocked
Me.SubFormDeathMarch.Locked = booLocked
Me.SubFormInterviewStatus.Locked = booLocked
Me.subformGhettoExperiences.Locked = booLocked
Me.subFormMigrationExperiences.Locked = booLocked
cboRecordLock.Locked = booLocked
txtDateLocked.Locked = booLocked
txtLockBy.Locked = booLocked
End If
End Sub
When the button if pressed TWO things must occur –
(1) the program checks to see if the record is already locked – if it is then the user is given a message that the record is already locked.
(2) If the record is not locked then – then the system must verify with the user that they want to indeed lock the record using an input from the message box.
I was able to get the form to lock initially however – because I am looking for two things – if the record is unlocked it will show the message box BUT if I select CANCEL – it still locks the record.
Here is the code:
Private Sub btnLockFile_Click()
If cboRecordLock = True Then
MsgBox "This Record is Already Locked " & vbCrLf & _
"and Can Not Be Unlocked or Altered", vbExclamation
Else
Dim cboInput As Boolean
Dim booLocked As Boolean
intResponse = MsgBox("You are About to Permanently Lock " & _
"This Record. If You Proceed," & vbCrLf & _
"This Record Will Be Disabled and Can Not Be " & vbCrLf & _
"Edited or Altered. To Continue Press YES" & vbCrLf & _
"or Press NO or CANCEL to Dismiss This Action", _
vbOKCancel + vbQuestion + vbDefaultButton1, _
"Critical Information")
cboInput = intResponse
If cboInput = 1 Then
cboRecordLock = cboInput
txtDateLocked = Date
txtLockBy = CurrentUser()
imgLock.Visible = True
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
booLocked = True
cboRecordLock.Locked = booLocked
txtDateLocked.Locked = booLocked
txtLockBy.Locked = booLocked
Me.txtFirst.Locked = booLocked
Me.txtLast.Locked = booLocked
Me.txtMaiden.Locked = booLocked
Me.txtPrefix.Locked = booLocked
Me.txtAddress.Locked = booLocked
Me.txtCity.Locked = booLocked
Me.txtState.Locked = booLocked
Me.txtZip.Locked = booLocked
Me.txtCountry.Locked = booLocked
Me.txtHomePhone.Locked = booLocked
Me.txtWorkPhone.Locked = booLocked
Me.txtEmail.Locked = booLocked
Me.subformCampExperiences.Locked = booLocked
Me.subformDPCampExperience.Locked = booLocked
Me.subformSovietExperience.Locked = booLocked
Me.subformRescuerExperience.Locked = booLocked
Me.SubFormLiberators.Locked = booLocked
Me.subformPOW.Locked = booLocked
Me.SubfrmResistance.Locked = booLocked
Me.subformHiding.Locked = booLocked
Me.SubFormPartisanExperience.Locked = booLocked
Me.SubFormDeathMarch.Locked = booLocked
Me.SubFormInterviewStatus.Locked = booLocked
Me.subformGhettoExperiences.Locked = booLocked
Me.subFormMigrationExperiences.Locked = booLocked
cboRecordLock.Locked = booLocked
txtDateLocked.Locked = booLocked
txtLockBy.Locked = booLocked
End If
End Sub