J
jonwitts
Guest
I have constructed a DB for work to record accidents, however I am running into problems. On each form I have a button that Saves the data closes the current form and opens the next form, depending on what data was entered. I have this ruuning fine using this code,
Private Sub SaveRecord_Click()
Dim NextForm As String
If Me.Status = "Pupil / Child" Then
NextForm = "StudentDetail"
Else
NextForm = "EmployerDetails"
End If
DoCmd.save
DoCmd.Close
DoCmd.OpenForm NextForm
End Sub
Private Sub SaveRecord_DblClick(Cancel As Integer)
Dim NextForm As String
If Me.Status = "Pupil / Child" Then
NextForm = "StudentDetail"
Else
NextForm = "EmployerDetails"
End If
DoCmd.save
DoCmd.Close
DoCmd.OpenForm NextForm
End Sub
The primary key of this form is "PersonKey" and the two forms taht could open, each have"PErsonKey" as a foriegn key. However the key does not get brought across into the next form and the save function does not appear to work on all forms...
I put another button on this form using the control button wizard, and it gave me this code,
Private Sub Command23_Click()
On Error GoTo Err_Command23_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_Command23_Click:
Exit Sub
Err_Command23_Click:
MsgBox Err.Description
Resume Exit_Command23_Click
End Sub
However when I run this from the form, it tells me that the "PersonKey" field needs a value....
Private Sub SaveRecord_Click()
Dim NextForm As String
If Me.Status = "Pupil / Child" Then
NextForm = "StudentDetail"
Else
NextForm = "EmployerDetails"
End If
DoCmd.save
DoCmd.Close
DoCmd.OpenForm NextForm
End Sub
Private Sub SaveRecord_DblClick(Cancel As Integer)
Dim NextForm As String
If Me.Status = "Pupil / Child" Then
NextForm = "StudentDetail"
Else
NextForm = "EmployerDetails"
End If
DoCmd.save
DoCmd.Close
DoCmd.OpenForm NextForm
End Sub
The primary key of this form is "PersonKey" and the two forms taht could open, each have"PErsonKey" as a foriegn key. However the key does not get brought across into the next form and the save function does not appear to work on all forms...
I put another button on this form using the control button wizard, and it gave me this code,
Private Sub Command23_Click()
On Error GoTo Err_Command23_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_Command23_Click:
Exit Sub
Err_Command23_Click:
MsgBox Err.Description
Resume Exit_Command23_Click
End Sub
However when I run this from the form, it tells me that the "PersonKey" field needs a value....