J
jturn00
I am not sure why. Ok, I might have a slight clue as it might relate to the
code below.
I have a contact form ("Contact Form") that by clicking a button opens a
detail note form ("Detail Form"). These are related by having an id field on
the Contact Form that relates to the Detail Form in a field DetailID. This
works fine. But when I am on the Detail Form and want to create a new record
(and copy the information) and in particular, use the same DetailID. When I
used the default button, it copies the information EXCEPT the DetailID.
The DetailID is also not passed when I use the standard Access create new
record arrows at the bottom of the page.
I think it has to do with how I have code to open the Detail Form from the
contact form below. But I am not sure. Command108_Click() is the button in
the Detail form where I want the DetailID to pass to the newly created Detail
Form record. OpenForm_Click() is the code to open the detail form (And
create a new record from the customer record).
Jeff
Option Compare Database
Private Sub CreateNewIssue_Click()
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
Me.UserCreated = fOSUserName()
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.DateModified = Now()
Me.UserModified = fOSUserName()
'Provide the user with the option to save/undo
'changes made to the record in the form
If MsgBox("Changes have been made to this record." _
& vbCrLf & vbCrLf & "Do you want to save these changes?" _
, vbYesNo, "Changes Made...") = vbYes Then
DoCmd.Save
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub
Private Sub UndoSubpoena_Click()
On Error GoTo Err_UndoSubpoena_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Exit_UndoSubpoena_Click:
Exit Sub
Err_UndoSubpoena_Click:
MsgBox Err.Description
Resume Exit_UndoSubpoena_Click
End Sub
Private Sub Form_Current()
Me!UndoSubpoena.Enabled = False
' With Me![Subpoena Comments Subform].Form
' .Visible = (.RecordsetClone.RecordCount > 0)
' End With
End Sub
Private Sub Form_Dirty(Cancel As Integer)
Me!UndoSubpoena.Enabled = True
End Sub
Private Sub OpenForm_Click()
On Error GoTo Err_OpenForm_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim stTeststring As String
stTeststring = "Test from click on button"
stDocName = "Subpoena Comments"
'stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
'DoCmd.GoToRecord acDataForm, stLinkCriteria, acNewRec
DoCmd.GoToRecord , , acNewRec
' DoCmd.RunCommand acCmdRecordsGoToNew
Me![Comment] = stTeststring
Me!UserCreated.Value = fOSUserName()
Me!UserModified.Value = fOSMachineName()
Me!DateCreated.Value = Now()
RunCommand acCmdSaveRecord
Exit_OpenForm_Click:
Exit Sub
Err_OpenForm_Click:
MsgBox Err.Description
Resume Exit_OpenForm_Click
End Sub
Private Sub Save_Subpoena_Detail_Click()
On Error GoTo Err_Save_Subpoena_Detail_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_Save_Subpoena_Detail_Click:
Exit Sub
Err_Save_Subpoena_Detail_Click:
MsgBox Err.Description
Resume Exit_Save_Subpoena_Detail_Click
End Sub
Private Sub Command108_Click()
On Error GoTo Err_Command108_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
Exit_Command108_Click:
Exit Sub
Err_Command108_Click:
MsgBox Err.Description
Resume Exit_Command108_Click
End Sub
code below.
I have a contact form ("Contact Form") that by clicking a button opens a
detail note form ("Detail Form"). These are related by having an id field on
the Contact Form that relates to the Detail Form in a field DetailID. This
works fine. But when I am on the Detail Form and want to create a new record
(and copy the information) and in particular, use the same DetailID. When I
used the default button, it copies the information EXCEPT the DetailID.
The DetailID is also not passed when I use the standard Access create new
record arrows at the bottom of the page.
I think it has to do with how I have code to open the Detail Form from the
contact form below. But I am not sure. Command108_Click() is the button in
the Detail form where I want the DetailID to pass to the newly created Detail
Form record. OpenForm_Click() is the code to open the detail form (And
create a new record from the customer record).
Jeff
Option Compare Database
Private Sub CreateNewIssue_Click()
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
Me.UserCreated = fOSUserName()
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.DateModified = Now()
Me.UserModified = fOSUserName()
'Provide the user with the option to save/undo
'changes made to the record in the form
If MsgBox("Changes have been made to this record." _
& vbCrLf & vbCrLf & "Do you want to save these changes?" _
, vbYesNo, "Changes Made...") = vbYes Then
DoCmd.Save
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub
Private Sub UndoSubpoena_Click()
On Error GoTo Err_UndoSubpoena_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Exit_UndoSubpoena_Click:
Exit Sub
Err_UndoSubpoena_Click:
MsgBox Err.Description
Resume Exit_UndoSubpoena_Click
End Sub
Private Sub Form_Current()
Me!UndoSubpoena.Enabled = False
' With Me![Subpoena Comments Subform].Form
' .Visible = (.RecordsetClone.RecordCount > 0)
' End With
End Sub
Private Sub Form_Dirty(Cancel As Integer)
Me!UndoSubpoena.Enabled = True
End Sub
Private Sub OpenForm_Click()
On Error GoTo Err_OpenForm_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim stTeststring As String
stTeststring = "Test from click on button"
stDocName = "Subpoena Comments"
'stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
'DoCmd.GoToRecord acDataForm, stLinkCriteria, acNewRec
DoCmd.GoToRecord , , acNewRec
' DoCmd.RunCommand acCmdRecordsGoToNew
Me![Comment] = stTeststring
Me!UserCreated.Value = fOSUserName()
Me!UserModified.Value = fOSMachineName()
Me!DateCreated.Value = Now()
RunCommand acCmdSaveRecord
Exit_OpenForm_Click:
Exit Sub
Err_OpenForm_Click:
MsgBox Err.Description
Resume Exit_OpenForm_Click
End Sub
Private Sub Save_Subpoena_Detail_Click()
On Error GoTo Err_Save_Subpoena_Detail_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_Save_Subpoena_Detail_Click:
Exit Sub
Err_Save_Subpoena_Detail_Click:
MsgBox Err.Description
Resume Exit_Save_Subpoena_Detail_Click
End Sub
Private Sub Command108_Click()
On Error GoTo Err_Command108_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
Exit_Command108_Click:
Exit Sub
Err_Command108_Click:
MsgBox Err.Description
Resume Exit_Command108_Click
End Sub