Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Improper use of null value 1

Status
Not open for further replies.

Jeddiah

Programmer
Apr 30, 2002
17
US
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

 
First of all, which line is giving you the Null error?

In addition, Strings can not be null. You should define those variables as VARIANT. You also can't compare against a Null value (for your <> test). You will need to use the function IsNull() to see if the field holds a value or not.

I hope this helps.
Janet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top