Error 3162 - "You tried to assign the Null value"

Joined
Feb 24, 2011
Messages
2
Reaction score
0
You tried to assign the Null value to a variable that is not a Variant data type. (Error 3162)

You tried to assign a Null value to a variable that is not a Variant data type. Use the Dim statement to declare the variable as a Variant, and then try the operation again.



Here's the situation as best I can describe it:

I am currently using Access 2003

Form - frmProperties
subform - frmPropertiesMortgageCompanies
control on subform - txtMortgageCompany

Private Sub txtMortgageCompany_AfterUpdate()
txtPropertieID = Forms![frmProperties]![txtPropertieID]
Forms![frmProperties]![txtPMCID] = txtPMCID
txtMCAddress1 = txtMortgageCompany.Column(2)
txtMCAddress2 = txtMortgageCompany.Column(3)
txtMCCity = txtMortgageCompany.Column(4)
txTMCState = txtMortgageCompany.Column(5)
txtMCZip = txtMortgageCompany.Column(6)
End Sub

The following References are used:
Visual Basic for Applications
Microsoft Access 11.0 Object Library
Microsoft Visual Basic for Applications Extensibility 5.3
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.1 Library
OLE Automation

Options - in order to find out what was happening, I set the Error Trapping to "Break on All Errors", but it does not break when this error comes up.


This error occurs every time that I enter any information in the combo box the first time. Once you click OK (only OK and Help on error message box and Help gives the message that is at the top), the information is accepted and it moves on to the "Not in List" code.

Private Sub txtMortgageCompany_NotInList(NewData As String, Response As Integer)
Dim strMessage As String
Dim db As Database
Dim rs As Recordset

strMessage = "Are you sure you want to add '" & NewData & _
"' to the list of Mortgage Companies?"

If Confirm(strMessage) Then
DoCmd.OpenForm "frmMortgageCompanies", , , , acFormAdd, acDialog
Response = acDataErrAdded
Else
If MsgBox(NewData & " is not a Mortgage Company in the list. " & vbCrLf & _
"Please pick a Mortgage Company from the list.", vbOKOnly) = vbOK Then
Me!txtMortgageCompany.Undo
Response = acDataErrDisplay
End If
End If
End Sub


I have tried to give you every thing that I can, but I just don't know what else to do. There are not variables that need to be set and I can't get this error to show me where the problem is.

Any help or answers that you can give me will be greatly appreciated. Thanking you in advance.
BJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top