Using MS Access/Run time error 94


Hi Scottgem

Hoping you can help with annoying problem in my database.  Beware I am a newbie!

I have a tabbed master form to allow entry of client data.  When I request a new record using navigation bttns or command button with vba I get same vba error msg stating:

'run time error 94, invalid use of null

when I select debug  I am shown vba code that links 2 fields on the client page: an image called ParticipantImage and a txt box  called ParticipantPhoto that has location of image file on network.

debug highlights second line in code below:

Private Sub Form_Current()

   ParticipantImage.Picture = ParticipantPhoto
End Sub

Can you see anything obvious that is causing my problem?  

Kind rgds Sue

The error message tells you the problem. When you go to a new record there is no data in the record. So no value for ParticipantPhoto so it defaults to Null. You can't assign a Null value to the Picture property of an image control.

Change your code to:

If NOT IsNull(Me.ParticipantPhoto) Then
   Me.ParticipantImage.Picture = Me.ParticipantPhoto
End If

You don't need the Me qualifier but I prefer to use it to make it clear I'm referring to a control on a form rather than a variable.

You can extend this by adding an ELSE clause which assigns a default image to the image control. I use an image that shows "Picture not available". But that's up to you.

Hope this helps,

Using MS Access

All Answers

Answers by Expert:

Ask Experts




I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.


I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Brooklyn College BA

©2016 All rights reserved.