Error 3162 - "You tried to assign the Null value" (1 Viewer)

bjgoen

New member
Local time
Yesterday, 18:37
Joined
Feb 24, 2011
Messages
6
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
 

boblarson

Smeghead
Local time
Yesterday, 16:37
Joined
Jan 12, 2001
Messages
32,059
Not sure if it will help but the first thing I see is you need to change this:

Dim db As Database
Dim rs As Recordset


to this:

Dim db As DAO.Database
Dim rs As DAO.Recordset
 

boblarson

Smeghead
Local time
Yesterday, 16:37
Joined
Jan 12, 2001
Messages
32,059
Also, this:
Code:
[INDENT]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)
 
[/INDENT]
Should be this:
Code:
[INDENT]Me.txtPropertieID = [B][COLOR=#ff0000]Me.Parent.[/COLOR][/B]txtPropertieID
[COLOR=red][B]Me.Parent.[/B][/COLOR]txtPMCID = [B][COLOR=#ff0000]Me.[/COLOR][/B]txtPMCID
[B][COLOR=#ff0000]Me.[/COLOR][/B]txtMCAddress1 = [B][COLOR=#ff0000]Me.[/COLOR][/B]txtMortgageCompany.Column(2)
[B][COLOR=#ff0000]Me.[/COLOR][/B]txtMCAddress2 = [B][COLOR=#ff0000]Me.[/COLOR][/B]txtMortgageCompany.Column(3)
[B][COLOR=#ff0000]Me.[/COLOR][/B]txtMCCity = [B][COLOR=#ff0000]Me.[/COLOR][/B]txtMortgageCompany.Column(4)
[COLOR=red][B]Me.[/B][/COLOR]txTMCState = [B][COLOR=#ff0000]Me.[/COLOR][/B]txtMortgageCompany.Column(5)
[B][COLOR=#ff0000]Me.[/COLOR][/B]txtMCZip = [B][COLOR=#ff0000]Me.[/COLOR][/B]txtMortgageCompany.Column(6)
[/INDENT]
 

bjgoen

New member
Local time
Yesterday, 18:37
Joined
Feb 24, 2011
Messages
6
I will try this, but this is all through my database as there is 96 forms, 220 reports, and 17 modules that may have this information in it, so before I go and change this, can you tell me more as to why I need to do this.

Also, this was a Access 2000 db that was upgraded to 2003 recently. Does this have anything to do with it?
 

bjgoen

New member
Local time
Yesterday, 18:37
Joined
Feb 24, 2011
Messages
6
Don't know if that did it, but did:
Me.txtPropertieID = Me.Parent.txtPropertieID
Me.Parent.txtPMCID = Me.txtPMCID
Me.txtMCAddress1 = Me.txtMortgageCompany.Column(2)
Me.txtMCAddress2 = Me.txtMortgageCompany.Column(3)
Me.txtMCCity = Me.txtMortgageCompany.Column(4)
Me.txTMCState = Me.txtMortgageCompany.Column(5)
Me.txtMCZip = Me.txtMortgageCompany.Column(6)

and now it works.

Thanks!
 

Users who are viewing this thread

Top Bottom