I've created some code that enables a user to copy an existing record to a new record, which looks like this:
This code is working fine, until it hits an empty field, and then I get an error message:
Is there some code I can use to tell it to skip any null fields?
Private Sub btnCopytoNewRecord_Click()
Dim Salutation As String
Dim First_Name As String
Dim Surname As String
'Copy fields to variables
Salutation = Me.Salutation
First_Name = Me.First_Name
Surname = Me.Surname
'Go to a new record
DoCmd.GoToRecord , , acNewRec
'Copy old values into new record
Me.Salutation = Salutation
Me.First_Name = First_Name
Me.Surname = Surname
End Sub
Dim Salutation As String
Dim First_Name As String
Dim Surname As String
'Copy fields to variables
Salutation = Me.Salutation
First_Name = Me.First_Name
Surname = Me.Surname
'Go to a new record
DoCmd.GoToRecord , , acNewRec
'Copy old values into new record
Me.Salutation = Salutation
Me.First_Name = First_Name
Me.Surname = Surname
End Sub
This code is working fine, until it hits an empty field, and then I get an error message:
Run time error '94':
Invalid use of Null
Invalid use of Null
Is there some code I can use to tell it to skip any null fields?