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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable not variant data type?

Status
Not open for further replies.

LittleRedHat

Instructor
Apr 20, 2001
202
GB
I have created an order form with a sub form based on Northwind. When I attempt to enter a product without first entering the customer I get "You have tried to assign the null value to a variable that is not the variant data type".

(Once ok'd all then runs as intended, i.e my error message is displayed, the boxes are cleared and the focus moves to customer.)

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr > 0 Then
If IsNull(Me.Parent!CustNo) Then
MsgBox "Please select a customer before entering order details", , "Mini Wheels"
RunCommand acCmdUndo
Me.Parent!CustNo.SetFocus
Response = acDataErrContinue
Else
Response = acDataErrDisplay
End If
End If

End Sub
~~~~~~~~~~~~~~~~~~~
I'm using a Combo Box that doesn't display the number but customer title and names with this the row source ...

SELECT DISTINCT [Customer].[CustNo] AS Expr1, [Customer].[Last_Name] AS Expr2, [Customer].[First_Name] AS Expr3 FROM Customer ORDER BY [Customer].[Last_Name];
~~~~~~~~~~~~~~~~~~~

I'd be grateful for any clues as to how to resolve.

WTA

LRH
 
Thanks and sorry to trouble you again ... but how do I do that? I've tried browsing help, but ended up more confused!

LRH
 
Private Sub Form_Error(DataErr As variant, Response As Integer)


MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Hi Michael,

That was what I tried following Bry's answer. When I try to compile I get "Procedure declaration does not match description of event or procedure having the same name" ... which was what sent me trawling through Help and getting lost!

Thanks

LRH
 
Hmmmmmmmmmmmmm,

I an guessing, but I would look for other instances of declarations of the 'names' in the declaration statement, such as "DataErr". If it is declared in the 'Scope' of the procedure, it WILL cause a problem. Usually, this would mean that it is 'declared' in the procedure, but it may occur if there is another procedure of the same name?

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
I agree with MRed . .there is something outside of the code you posted that is causing this. The original error indicates that Access was passing a null to DataErr, which prompted me to suggest defining DataErr as Variant.

I can see in some of Microsoft's example code that they always define DataErr as Integer, as you did originally. Apparently, there should be no situation in which a null is passed to DataErr, however it seems to be happening in your case.

I'm stumped! - - - -

Bry
 
My thanks to both of you.

I had thoughts along the same lines and have checked and double checked through both the sub and parent forms. It's the only "DataErr" and I can't find anything that I think is causing the problem.

It seems I'll have to go back to the drawing board. Looks like I could be in for a long night!!!

With thanks again ...

LRH



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top