I was working on two forms trying to sync them for data entry, but since there are some records that don't have correspondent records I needed for form1 to create one for it when it openes. I'm not that great with programming but have peiced together a little something, something (from here and there) that I hope will work. I keep getting an error the say wrong use of null value. Can someone take a look and tell me what I'm doing worng here. This is using Access.Private Sub Command346_Click()
On Error GoTo Err_Command346_Click
Dim stDocName As String
Dim PatientID, LastName, FirstName As String
stDocName = "ClinicInfo"
'Store the calling form's (PnoneIntakeLog PatientID,
'LastName, FirstName, PatientID to add to new form ClinicInfo
'if needed.
[PatientID] = Me![PatientID]
[FirstName] = Me![FirstName]
[LastName] = Me![LastName]
'Open form2, goto the matching PatientID field
DoCmd.OpenForm stDocName, , , , acFormEdit, , PatientID]
'Find the first record in table2 (form2) that matches
DoCmd.FindRecord [PatientID], , True, , True, , True
'If the PatientID do not match (not found in table 2) then
'this must be a new record so add a new record and populate the
'listed field on form 2
If [PatientID] <> Me![PatientID] Then
DoCmd.GoToRecord , , acNewRec
Forms!stDocName![PatientID] = [PatientID]
Forms!stDocName![FirstName] = [FirstName]
Forms!stDocName![LastName] = [LastName]
End If
Exit_Command346_Click:
Exit Sub
Err_Command346_Click:
MsgBox Err.Description
Resume Exit_Command346_Click
End SubEnd Sub
On Error GoTo Err_Command346_Click
Dim stDocName As String
Dim PatientID, LastName, FirstName As String
stDocName = "ClinicInfo"
'Store the calling form's (PnoneIntakeLog PatientID,
'LastName, FirstName, PatientID to add to new form ClinicInfo
'if needed.
[PatientID] = Me![PatientID]
[FirstName] = Me![FirstName]
[LastName] = Me![LastName]
'Open form2, goto the matching PatientID field
DoCmd.OpenForm stDocName, , , , acFormEdit, , PatientID]
'Find the first record in table2 (form2) that matches
DoCmd.FindRecord [PatientID], , True, , True, , True
'If the PatientID do not match (not found in table 2) then
'this must be a new record so add a new record and populate the
'listed field on form 2
If [PatientID] <> Me![PatientID] Then
DoCmd.GoToRecord , , acNewRec
Forms!stDocName![PatientID] = [PatientID]
Forms!stDocName![FirstName] = [FirstName]
Forms!stDocName![LastName] = [LastName]
End If
Exit_Command346_Click:
Exit Sub
Err_Command346_Click:
MsgBox Err.Description
Resume Exit_Command346_Click
End SubEnd Sub