Run Time Error 94 Invalid Use of Null

N

Norm

When trying to sync data I encounter the Run-Time Error I placed brackets
around the issue that is highlighted in yellow below in the program,should I
change the =rs.Fields(0) to reflect =rs.Fields(1)?


Do While Not rs.EOF
Dim strWMS As String
{strWMS = rs.Fields(0)}
updateJob strWMS, Cnxn, db
rs.MoveNext
Me.mainSyncProgressBar = i / rcCountInt * 100
Me.mainSyncProgressBar.Refresh
Dim istr As String
istr = i
Me.statusText.value = istr + " of " + rcCountStr + " jobs updated "
Me.SetFocus
Me.Refresh
Me.Repaint
i = i + 1
Loop
wrkDefault.CommitTrans
rs.Close
 
J

John Spencer

Hard to say, but is the first field Null at times? If so, you cannot assign
that to a string variable.


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
J

John Spencer

It kind of depends on what you want to do if the field is null.

The simplest solution would be to test the value of the field and skip to
the next record in the recordset,. Since I don't know what updateJob is
doing I don't know if that is a good solution.

IF IsNull(rs.Fields(0)) = False THEN
strWMS = ...
updateJob ...
End If
rs.MoveNext

If you need to process the record anyway, then you can use
strWMS = NZ(rs.Fields(0),"")
to force a zero-length string into strWMS. That can be a problem is
upDateJob does not know what to do with a zero length string or (guessing
here) the field in the table cannot accept zero-length strings.


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
N

Norm

Good Morning John,
I took your advice on useing strWMS = NZ(rs.Fields(0),"") and it worked.

Thank you.
 
N

Norm

Good Morning Keith,

I took your advice and used Use the NZ function to assign a value to it, eg
assign a "0":
strWMS = Nz(rs.Fields(0),0)
and the program is working fine now.

Thank you
 
K

Keith Wilby

Norm said:
Good Morning Keith,

I took your advice and used Use the NZ function to assign a value to it,
eg
assign a "0":
and the program is working fine now.

Thank you

You're welcome, glad I could help.

Keith.
 

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