Using MS Access/Run time error 94
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
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
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,