Debugging a Runtime Error '94'

S

Sondra

I have two databases with the same type of On Open Event on one of the forms;
however on one form it isn't work and I'm getting a Runtime Error '94'. I
don't have a clue what this means and because the other one is working I'm
having some problems figuring it out.

here is my Procedure:

Private Sub Form_BeforeInsert(Cancel As Integer)

Dim mTable As String, mField As String, mYearPart As Long, mNextNumber
As Long
'number is returned as 6 characters: YY####
'where YY is the last 2 digits of the year
'#### is the next number for that year
'C is the CSCR Code
'format code to display this number should be "00C-0000"
mTable = "CSCR"
mField = "CSCRNumber"
mYearPart = Right(CStr(Year(Me.CSCRYear)), 2) * 10000
mNextNumber = Nz(DMax(mField, mTable, mField & ">=" & mYearPart), 0)

If mNextNumber = 0 Then
mNextNumber = mYearPart
End If

mNextNumber = mNextNumber + 1
Me.CSCRNumber = mNextNumber

End Sub

The line:

mYearPart = Right(CStr(Year(Me.CSCRYear)), 2) * 10000

is where the Runtime Error is pointing to.

Any help would be appreciated.

Thanks.
 
T

TC

Was the error message text, "Invalid use of null"? (You should really
tell us. It's not fair making people guess what the message actually
said!)

If so, Me.CSCYear has a null value - there is nothing in it. So you
should check for that first:

if is null(me.cscryear) then
' do this
else
myearpart = ... etc.
endif

HTH,
TC
 

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