brewpedals
Registered User.
- Local time
- Today, 09:34
- Joined
- Oct 16, 2002
- Messages
- 32
Can you please take a look at this code and tell me what I'm doing wrong?
Objects on the form are not enabled on new records even if my criteria matches??
This code is on the click event of a "New Record" button that launches lauches a form, creates a new record and puts the userID into the OwnerID field.
This is the form open event code that first checks to see if it's a new record then saves the record to record the userID as the ownerID in the record the sets permissions to objects.
Thanks so much for your time - it's a lot of code to weed through!
Brew.
Objects on the form are not enabled on new records even if my criteria matches??
This code is on the click event of a "New Record" button that launches lauches a form, creates a new record and puts the userID into the OwnerID field.
Code:
Private Sub cmd_AddNew_Click()
On Error GoTo Err_cmd_AddNew_Click
Dim stDocName As String
stDocName = "frm_DMSS"
DoCmd.OpenForm stDocName
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."
DoCmd.GoToRecord acDataForm, stDocName, acNewRec
[B]Forms!frm_DMSS!txt_OwnerID.Value = Forms!frm_DetectIdleTime!UserID.Value[/B]
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
This is the form open event code that first checks to see if it's a new record then saves the record to record the userID as the ownerID in the record the sets permissions to objects.
Code:
Private Sub Form_Open(Cancel As Integer)
Dim strUserID As Single
Dim strOwnerID As Single
If Me.Dirty Then
Me.Dirty = False
Else
GoTo SetPermissions
End If
SetPermissions:
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 Sub
Thanks so much for your time - it's a lot of code to weed through!
Brew.