error 94 - unlegal use of null

odrap

Registered User.
Local time
Today, 13:38
Joined
Dec 16, 2008
Messages
156
In my subform sfrmOrders i have the following code in relation to the field "Qty". Normaly after entering aa amount in this field ,the program calculates the amount that can be delivered, based on the amount of stock. But no amount appears in the field "Delvered" In order to find out what is happening, i placed a messagebox in the code ( see red colored code). Whe i run the program now i get the message : Error 94 , unproper ( or unlegal ) i do not know the exact translation ) of NULL.
In my table tblOrderdetails, the field 'Deliverd is of typ numeric, long integer, precisely the same as for the field "Qty' for which i do not get this error message. What's going on here?



Private Sub Qty_Click()

On Error GoTo ErrorHandler

PresentQty = Nz(Me![Qty], 0)
Presentbackorder = Nz(Me![Backorder], 0)

Afsluiten:
On Error GoTo 0
Exit Sub
ErrorHandler:
Mededeling = foutbericht("Qty_Click", "sfrmOrders", Err.Number)
Resume Afsluiten
End Sub

Private Sub Qty_BeforeUpdate(Cancel As Integer)

On Error GoTo ErrorHandler
If Me!Qty = 0 Or Me!Qty & "" = "" Then
MsgBox ("The Qty must be larger then 0 ")
DoCmd.CancelEvent
End If
Afsluiten:
On Error GoTo 0
Exit Sub
ErrorHandler:
Mededeling = foutbericht("Qty_BeforeUpdate", "sfrmOrders", Err.Number)
Resume Afsluiten
End Sub

Private Sub Qty_AfterUpdate()

On Error GoTo ErrorHandler
...

ElseIf QTY > PresentQty Then
Toename = Qty - PresentQtY
If Stock > 0 Then
If Stock >= Toename Then
Delivered = Delivered + Toename
MsgBox " delivered is " & Cstr(Delivered)
Voorraad = Voorraad - Toename
...
...

Afsluiten:
On Error GoTo 0
Exit Sub

ErrorHandler:
Mededeling = foutbericht("QTY_AfterUpdate", "sfrmOrders", Err.Number)
Resume Afsluiten
End Sub
 
Either Delivered or Toename is null. Test for that 1st with IsNull(YourVar)
 
I tested delivered, and indeed delivered is null!!! Is it possible that the reason herefore sticks in the table where the field is created? Is it necessary to give that field a default value = 0 in the table ?
 
Delivered = Nz([Delivered],0) + Nz([Toename],0)
...should take care of this problem.
 

Users who are viewing this thread

Back
Top Bottom