BusyBeeBiker
New member
- Local time
- Today, 20:10
- Joined
- Jun 27, 2021
- Messages
- 26
1. I have a form frmPersonnel which logs persons name address etc.
2. On that form I have a new record button which brings up new record based upon click event below:
DIM strBookMark as variant - Set at top of form module frmPersonnel so available to all sub procedures in module.
Private Sub cmbAddNew_Click()
If Forms!frmLoginScreen!numSecurityLevel >= 8 Then ' Checks Security Clearance
strBookMark = Me.Bookmark 'Set Bookmark for current record
Call addNewRecord("frmPersonnel", "fkTitleID") ' Add New Record Function
Me!frmStatusSubForm.Form.AllowAdditions = True ' Set Allow Additions Default Setting.
' Me.fkTitleID = ""
Me.fkTitleID.SetFocus
Call modTracking(Me.Name, 1, Environ("ComputerName"), Environ("UserName"), "") ' Tracks Addition of Record to WLP System.
End If
ExitHere: ' Any Clean Up Code
Err.Clear
Exit Sub
End Sub
3. What I want to do is when user is asked to whether to save New Record or Abandon it, on abandonment of record, I want it to return to the previous record selected , to which end I have used the code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
' Dimension Variables
Dim Response, strMessage As String
If Me.Dirty = True Then ' Validates if Record is Dirty.
If Me.NewRecord = True Then ' Validates if New Record
' Validate that Surname has Entered is a NEW record.
If IsNull(txtSurname) Then
' Initialise Message String.
strMessage = "Cannot Save Record Without Surname." & vbCrLf _
& "Select YES to return to Surname Field." & vbCrLf _
& "Select NO to Abandon Change(s). Return to Previous Record."
Response = MsgBox(strMessage, vbYesNo)
If Response = vbNo Then
Cancel = True
Me.Bookmark = strBookMark
Me.Requery
Me.txtSearch.SetFocus
GoTo ExitHere:
Else
Me.txtSurname.SetFocus
GoTo ExitHere:
End If
End If
' Asks User to Save Record or Not!
Response = MsgBox("Save New Record?", vbYesNo)
If Response = vbNo Then
Cancel = True
End If
End If
End If
ExitHere: ' Any Clean Up Code
Err.Clear
End Sub
4. I have used bookmarking to try to elicit this response (In Green) but on third line of this green coding get the error message
"Error 3159 Not a valid bookmark"
When I check strBookMark doesn't have a value as it says Empty. but a populated it first with strBookMark = Me.Bookmark 'Set Bookmark for current record.
Been trying for 2 days to resolve this issue and getting nowhere fast.
2. On that form I have a new record button which brings up new record based upon click event below:
DIM strBookMark as variant - Set at top of form module frmPersonnel so available to all sub procedures in module.
Private Sub cmbAddNew_Click()
If Forms!frmLoginScreen!numSecurityLevel >= 8 Then ' Checks Security Clearance
strBookMark = Me.Bookmark 'Set Bookmark for current record
Call addNewRecord("frmPersonnel", "fkTitleID") ' Add New Record Function
Me!frmStatusSubForm.Form.AllowAdditions = True ' Set Allow Additions Default Setting.
' Me.fkTitleID = ""
Me.fkTitleID.SetFocus
Call modTracking(Me.Name, 1, Environ("ComputerName"), Environ("UserName"), "") ' Tracks Addition of Record to WLP System.
End If
ExitHere: ' Any Clean Up Code
Err.Clear
Exit Sub
End Sub
3. What I want to do is when user is asked to whether to save New Record or Abandon it, on abandonment of record, I want it to return to the previous record selected , to which end I have used the code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
' Dimension Variables
Dim Response, strMessage As String
If Me.Dirty = True Then ' Validates if Record is Dirty.
If Me.NewRecord = True Then ' Validates if New Record
' Validate that Surname has Entered is a NEW record.
If IsNull(txtSurname) Then
' Initialise Message String.
strMessage = "Cannot Save Record Without Surname." & vbCrLf _
& "Select YES to return to Surname Field." & vbCrLf _
& "Select NO to Abandon Change(s). Return to Previous Record."
Response = MsgBox(strMessage, vbYesNo)
If Response = vbNo Then
Cancel = True
Me.Bookmark = strBookMark
Me.Requery
Me.txtSearch.SetFocus
GoTo ExitHere:
Else
Me.txtSurname.SetFocus
GoTo ExitHere:
End If
End If
' Asks User to Save Record or Not!
Response = MsgBox("Save New Record?", vbYesNo)
If Response = vbNo Then
Cancel = True
End If
End If
End If
ExitHere: ' Any Clean Up Code
Err.Clear
End Sub
4. I have used bookmarking to try to elicit this response (In Green) but on third line of this green coding get the error message
"Error 3159 Not a valid bookmark"
When I check strBookMark doesn't have a value as it says Empty. but a populated it first with strBookMark = Me.Bookmark 'Set Bookmark for current record.
Been trying for 2 days to resolve this issue and getting nowhere fast.