brewpedals
Registered User.
- Local time
- Today, 05:44
- Joined
- Oct 16, 2002
- Messages
- 32
Hi all,
I have one form whose record source is a table. I am attempting to use the same form to both add new records and edit records. I also use a hidden form to store the users ID for comparison to prevent users from editing records they did not create.
My problem is I can not create a new record unless the users ID matches the user ID in the first record? I get the error:
" You can't go to the specified record. You may be at the end of a recordset."
frm_DMSS is the form I use to add & edit records
frm_DetectIdleTime is the form I use to store the user ID
Here is my Form Open Code for frm_DMSS :
Here is my New record code I use to launch frm_DMSS:
Many thanks for your time and help.
I have one form whose record source is a table. I am attempting to use the same form to both add new records and edit records. I also use a hidden form to store the users ID for comparison to prevent users from editing records they did not create.
My problem is I can not create a new record unless the users ID matches the user ID in the first record? I get the error:
" You can't go to the specified record. You may be at the end of a recordset."
frm_DMSS is the form I use to add & edit records
frm_DetectIdleTime is the form I use to store the user ID
Here is my Form Open Code for frm_DMSS :
Code:
Private Sub Form_Open(Cancel As Integer)
Dim strUserID As Single
Dim strOwnerID As Single
strUserID = Forms!frm_DetectIdleTime!UserID.Value
strOwnerID = Me!txt_OwnerID.Value
Select Case strOwnerID
Case Is = strUserID
Me.[Form].[AllowAdditions] = True
Me.[Form].[AllowEdits] = True
Me.[Form].[AllowDeletions] = True
Case Is <> strUserID
Me.[Form].[AllowAdditions] = False
Me.[Form].[AllowEdits] = False
Me.[Form].[AllowDeletions] = False
Me.Rev_date.OnClick = ""
Me.cmd_Delete_doc.Enabled = False
Me.cmd_delete_file.Enabled = False
Me.cmd_send.Enabled = False
Me.cmd_browse.Enabled = False
Me.Frame372.Enabled = False
Me.Child399.Enabled = False
Me.ctl_subfrm_DMSS_Access.Enabled = False
Me.ctl_subfrm_DMSS_Controls.Enabled = False
Me.ctl_subfrm_DMSS_Revision.Enabled = False
Me.ctl_subfrm_DMSS_Roles.Enabled = False
End Select
End Sub
Here is my New record code I use to launch frm_DMSS:
Code:
Private Sub cmd_AddNew_Click()
On Error GoTo Err_cmd_AddNew_Click
Dim stDocName As String
stDocName = "frm_DMSS"
DoCmd.OpenForm stDocName
DoCmd.GoToRecord acDataForm, stDocName, acNewRec
Forms!frm_DMSS!txt_OwnerID.Value = Forms!frm_DetectIdleTime!UserID.Value
Forms!frm_DMSS!DataEntry = True
Forms!frm_DMSS!AllowAdditions = True
Forms!frm_DMSS!AllowEdits = True
Forms!frm_DMSS!Form.Caption = "Create a NEW Document record."
Forms!frm_DMSS!Date = Date
Forms!frm_DMSS!txt_Plant.Value = DLookup("[Plant_ID]", "tbl_Users", "[ID] =" & Forms!frm_DetectIdleTime!UserID.Value)
Exit_cmd_AddNew_Click:
Exit Sub
Err_cmd_AddNew_Click:
MsgBox Err.Description
Resume Exit_cmd_AddNew_Click
End Sub
Many thanks for your time and help.
Last edited: