error: you tried to assign the Null value to a . . .

B

bfreeman

Hi all,

I am receiving an error from my combo box. I set it up to be able t
double-click the drop-down and it opens a form so you can ad
information to it.

The error reads as follows:

"You tried to assign the Null value to a variable that is not a Varian
data type."

Basically, all the drop down is physician names and when one i
selected the fields (salutation, name, phone, etc.) are displayed. T
add additional physicians is my goal. My code is below:

Private Sub Form_Load()
If Me.OpenArgs = "GotoNew" And No
IsNull(Me![Volunteers_PhysicianID]) Then
DoCmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
End If
End Sub

Private Sub Volunteers_PhysicianID_NotInList(NewData As String
Response As Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub

Private Sub Volunteers_PhysicianID_DblClick(Cancel As Integer)
On Error GoTo Err_Volunteers_PhysicianID_DblClick
Dim lngVolunteers_PhysicianID As Long

If IsNull(Me![Volunteers_PhysicianID]) Then
Me![Volunteers_PhysicianID].Text = ""
Else
lngVolunteers_PhysicianID = Me![Volunteers_PhysicianID]
Me![Volunteers_PhysicianID] = Null
End If
DoCmd.OpenForm "Physician", , , , , acDialog, "GotoNew"
Me![Volunteers_PhysicianID].Requery
If lngVolunteers_PhysicianID 0 Then Me![Volunteers_PhysicianID]
lngVolunteers_PhysicianID

Exit_Volunteers_PhysicianID_DblClick:
Exit Sub

Err_Volunteers_PhysicianID_DblClick:
MsgBox Err.Description
Resume Exit_Volunteers_PhysicianID_DblClick
End Sub

Any suggestions or solutions are appreciated. Thanks in advanced.

-Free
 
K

Ken Snell

May be completely unrelated, but these two lines of code are not correct:

If lngVolunteers_PhysicianID 0 Then Me![Volunteers_PhysicianID] =
lngVolunteers_PhysicianID

I believe they should be

If lngVolunteers_PhysicianID = 0 Then Me![Volunteers_PhysicianID] = _
lngVolunteers_PhysicianID

When you get the error message, click Debug in the message box and see which
line of code is highlighted as the source of the error. Need to know that in
order to help you.
 

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