jujubeanster
New member
- Local time
- Today, 03:06
- Joined
- Sep 17, 2015
- Messages
- 3
Hello,
So I'm building a database in Access 2007 and I have a form that the user fills out with beginning information and on click of the next button it navigates to the proper form and takes all of the information and pushes it to the newly opened form. I'm getting the error when I try to write to the form. Can anyone help? My code is listed below:
Private Sub NextCommand_Click()
Dim strForm As String
Dim ptID As String
ptID = Me.PatientID
If Len(Nz(Me.PatientID, vbNullString)) = 0 Or Len(Nz(Me.AdmissionDate, vbNullString)) = 0 Or Len(Nz(Me.DischargeDate, vbNullString)) = 0 Or Len(Nz(Me.Team, vbNullString)) = 0 Then
MsgBox "Error: All fields must be completed."
Exit Sub
ElseIf Me.CurrentResidence = "Residence" And Me.DischargeType = "1" Then
strForm = "Audit Table"
Else: MsgBox "Error: All fields must be completed."
Exit Sub
End If
DoCmd.OpenForm strForm
[Forms]![strForm].[Patient ID] = ptID
End Sub
The line [Forms]![strForm].[Patient ID] = ptID isn't running properly with strForm in it, but once I change it to "Audit Table" then it works just fine. I need to be able to put a variable in it because the code is actually a lot longer and cycles through 10 different forms based on the entered data....
Helppp
So I'm building a database in Access 2007 and I have a form that the user fills out with beginning information and on click of the next button it navigates to the proper form and takes all of the information and pushes it to the newly opened form. I'm getting the error when I try to write to the form. Can anyone help? My code is listed below:
Private Sub NextCommand_Click()
Dim strForm As String
Dim ptID As String
ptID = Me.PatientID
If Len(Nz(Me.PatientID, vbNullString)) = 0 Or Len(Nz(Me.AdmissionDate, vbNullString)) = 0 Or Len(Nz(Me.DischargeDate, vbNullString)) = 0 Or Len(Nz(Me.Team, vbNullString)) = 0 Then
MsgBox "Error: All fields must be completed."
Exit Sub
ElseIf Me.CurrentResidence = "Residence" And Me.DischargeType = "1" Then
strForm = "Audit Table"
Else: MsgBox "Error: All fields must be completed."
Exit Sub
End If
DoCmd.OpenForm strForm
[Forms]![strForm].[Patient ID] = ptID
End Sub
The line [Forms]![strForm].[Patient ID] = ptID isn't running properly with strForm in it, but once I change it to "Audit Table" then it works just fine. I need to be able to put a variable in it because the code is actually a lot longer and cycles through 10 different forms based on the entered data....
Helppp