neuroman9999
Member
- Local time
- Yesterday, 21:37
- Joined
- Aug 17, 2020
- Messages
- 827
can any of you experts tell me if makes any sense whatsoever? I have a scenario where security paranoia is running rampant in a large American bank, who I am working for. I know what to do, obviously, but there are endless ways to tackle stuff like this. Here is what I am currently doing:
when a new main form record is entered, it has to be assigned a status, however, that status cannot be assigned and put into the binding until a sign off form is filled out and a UN and hashed PW is checked. so, here's a sample of code, that is not that efficient, behind the main form:
and even though that code is a tad bit wrong, there are other parts of the app that make perfect sense. for instance, in another area, there is this code:
and the called function in the form's module is:
can anyone see how this can be reduced? it's not a big deal, but none-the-less, there is still more code written than need be, obviously. thanks.
when a new main form record is entered, it has to be assigned a status, however, that status cannot be assigned and put into the binding until a sign off form is filled out and a UN and hashed PW is checked. so, here's a sample of code, that is not that efficient, behind the main form:
PHP:
Private Sub btnSaveRec_Click()
If Me.NewRecord Then
If Me.Dirty Then
If validate_Controls_Private("status", "statusnotification") Then
Me.btnApprove.Enabled = True
Me.Status = "entered"
Me.statusnotification = "Entered, Awaiting Approval"
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm "frmSignOff"
Else
MsgBox "All fields must be filled in for new records.", vbCritical, "Error"
End If
Else
MsgBox "No data has been entered for this record.", vbCritical, "Error"
End If
Else 'record NOT NEW
If Me.Dirty Then
If Me.Status = "approved" Then 'record already locked
MsgBox "This record cannot be modified or saved because " & vbCrLf & _
"it has already been approved and signed. It is " & vbCrLf & _
"locked permanently.", vbCritical, "Error"
Me.Undo
Else
DoCmd.RunCommand (acCmdSaveRecord)
MsgBox "Record has been saved.", vbInformation, "Confirm"
End If
Else
MsgBox "No changes have been made to the record." & vbCrLf & _
"Record cannot be saved.", vbCritical, "Error"
End If
End If
End Sub
PHP:
Private Sub btnClose_Click()
If Me.NewRecord Then 'IS new record.
If Me.Dirty Then 'new record entry has been started.
If validate_Controls_Private("status", "statusnotification") Then 'if all fields filled in.
If MsgBox("You have not saved the current record." & vbCrLf & _
"Would you like to do so before closing the form?", vbYesNo + vbExclamation, "Confirm") = vbYes Then
MsgBox "Saving new records requires you to sign off on the process." & vbCrLf & _
"You will now be redirected to the Sign Off form....", vbExclamation, "Alert"
DoCmd.OpenForm "frmSignOff"
Else
Me.Undo
DoCmd.Close acForm, Me.Name
End If
Else 'some fields are NOT filled in, ask if user wants to abondon efforts.
If MsgBox("All fields must be filled in for new records." & vbCrLf & _
"Would you like to cancel this record entry and close the form?", vbYesNo + vbExclamation, "Confirm") = vbYes Then
Me.Undo
DoCmd.Close acForm, Me.Name
End If
End If
Else
DoCmd.Close acForm, Me.Name
End If
Else 'NOT a new record.
If Me.Dirty Then 'OLD records can ONLY be edited if ''status'' = ''entered''. record HAS been edited.
If MsgBox("You have made changes to the current record." & vbCrLf & _
"Would you like to save your changes before closing the form?", vbYesNo + vbExclamation, "Confirm") = vbYes Then
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Record has been saved.", vbInformation, "Confirm"
DoCmd.Close acForm, Me.Name
Else
Me.Undo
DoCmd.Close acForm, Me.Name
End If
Else 'record NOT edited.
DoCmd.Close acForm, Me.Name
End If
End If
End Sub
PHP:
Private Function validate_Controls_Private(exclude As String, exclude2 As String) As Boolean
For Each c In Me.controls
If TypeOf c Is TextBox And (c.Name <> exclude And c.Name <> exclude2) Then
If (c = "" Or IsNull(c)) Then
validate_Controls_Private = False
Exit Function
End If
End If
Next c
validate_Controls_Private = True
End Function