Results 1 to 11 of 11
  1. #1
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618

    Image. Error Use of Null.

    I watched a few tutorials and read a bit, solution still outstanding. I placed an Image on the form. The image shows, so the little VBA must be correct. As soon as I ADD NEW, the error “Invalid use of Null.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Have no idea what you are talking about. How is VBA connected with placing image on form? Post your code.

    You ADD NEW where?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Table t01Image to store a lot of images, Logos and documents for the database. Some say you can not use two field names with DATA TYPE Attachment. I want three on various forms, so I am trying to use IMAGE, Ole Object, and Attachment since they are capable of different results which suits me. Someone said there is a way to use multiple fields with data type ATTACHMENT. Do you know how or have a link to advice?

    To answer you on the current thread. To use IMAGE. I opened table t01Image One descriptive field lets say NAME. Another field Logo01. In logo01 I store the reference to the Image say C:\Images\Photo1.jpg. Many images in c:\Images. Opened a query q01Image and form f01Image. On the form I placed an image from the design box, named the image LOGOIMAGE. In the VBA page I added as the tutorial taught me:

    Private Sub Form_Current()
    LogoImage.Picture = Logo01
    End Sub

    When in Form View I see the Image. Everything fine so far. Then when click on add to add the next image against the next record it shows the error. "Invalid use of Null". If I click "End" it allows me to continue and I can add the next image to the next record and it all works. I don't see any field with Null value, there are only 2 fields. Is it the next field that it doesn't want to see.
    Thank you.

  4. #4
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    I downloaded a tutorial on a setup of a page from Youtube. "Images store into MS Access data base use of vb visual basic 2010 part 7". It probably teaches me exactly what I need to know to build an easy page to load images. My first language is also not English but this guy's Asian accent not so easy for me. If you know of another tutorial that can teach me to setup a page like that, let me know please.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I have never had good experience with the OLEObject control.

    Apparently the Picture property cannot handle Null. When you start new record the Logo01 field is Null.

    I don't use Picture property to dynamically display images. I use the ControlSource property of Image control. The file path can be constructed in the ControlSource. If you store the file path in a text field, just bind the Image control to that field. No VBA needed. VBA and Picture property were required before the ControlSource property was added to the ImageControl with Access 2007.


    Not understanding what you mean by 'multiple fields with data type ATTACHMENT'. Did you mean 'files'?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    SodaPop is offline Novice
    Windows 8 Access 2007
    Join Date
    Mar 2014
    Posts
    16
    On error resume next

    If it works when you step through after error u should be able to skip it and reset your error control after. However you may need to use nz() to handle the null value if skipping the error doesn't work real time.

    Sent from my SM-G950U using Tapatalk

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Quote Originally Posted by Perfac View Post
    Table t01Image to store a lot of images, Logos and documents for the database. Some say you can not use two field names with DATA TYPE Attachment. I want three on various forms, so I am trying to use IMAGE, Ole Object, and Attachment since they are capable of different results which suits me. Someone said there is a way to use multiple fields with data type ATTACHMENT. Do you know how or have a link to advice?
    You CAN have multiple attachment type fields in a table but in my opinion the correct number to use is ZERO.
    Using attachment fields causes significant bloat in database size and offers no real advantages
    Instead store the file path(s) as text fields and use code such as:
    Code:
    Me.ImageFrame.Picture = Me.lstImages
    Disagree with sodapop regarding use of error handling code
    I would use proper error handling code but it should also be kept for 'production use'

    Errors may not occur (or get fixed) during development but they may still occur later in different circumstances
    If you use ACCDE files without proper error handling, the app will crash
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Because I am still learning I would like to test those three options of placing Logo, Photo, image or documents on the forms. I met Mr Gates personally in South Africa(in a hospital), and for MicroSoft I have a lot of respect. I believe Access is the most popular database. Surely there are still errors even though I assume many 1000’s test Access and its been decades now. So these 3 options I assume, they work, if I don’t get it to work I need to learn how, but they should work . I test those 3 different options on the same form in my development.
    Lets say I have a 100 customers in a table and adding. I use IMAGE from the control to place Logos. I chose to use OLE objects to place Photos of customers and the choice ATTACHMENT in table to place and store DOCUMENTS.
    What I learnt so far.
    1. The IMAGE CONTROL I place with a file path since when I alternate between those customers, it alternate between the images . If I place it with Source control as you suggest, Access does not alternate, or am I missing something? How do you tag different images to different records through record source. A benefit is this option stores images outside Access. Only one image can be stored. I still want to learn and test if multiple images can be placed on one form.
    2. OLE OBJECT, only by creating a field in a table. When creating a form I drag the field on the form. Copy and paste images into it. There is no path to define? I am not sure but it seems certain format of images if you click on it it inside the OLE object and it opens the image, others don’t. Only one image can be stored inside one OLE object? I still want to learn and test if multiple OLE objects can be placed on one form. It takes space inside Access?
    3. ATTACHMENT. Only by choice of field type ATTACHMENT in a table. No path to define. I store documents on forms. They say you can create two such attachments in a table but can’t place mutliple on a form, I will test some more. I place it on a form by dragging it when creating the form. When placed on a form I linger the mouse over the ATTACHMENT box. A hairpin appears which allows multiple images or documents to be placed.
    All three displays images fine for me so far. Do you know if either one can be used multiple of them on one form, or does these three different ones clash or have issues being placed on the same form?
    Sorry for the long story, but it seems I need more time than what I have available.

  9. #9
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Thanks Ridders. As said I believe the Images does not cause bloat to the system. The others does. For the code I will add the Me. in front of my code as well, although Richard Rost doesn't mention it on his tutorials. I agree what you comment on Sodapop. In a simple test I created a table and query with just two fields. They all store data, even if I test just three records. No fields without data, and it still error "Invalid use of Null".

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Quote Originally Posted by Perfac View Post
    Thanks Ridders. As said I believe the Images does not cause bloat to the system. The others does. For the code I will add the Me. in front of my code as well, although Richard Rost doesn't mention it on his tutorials. I agree what you comment on Sodapop. In a simple test I created a table and query with just two fields. They all store data, even if I test just three records. No fields without data, and it still error "Invalid use of Null".
    Using the attachment datatype DOES cause significant database bloat.
    The most efficient method of handling images is to save the filepath as I mentioned before

    Using Me. allows the use of Intellisense in code - no idea who Richard Rost is

    Have a look at the attached example database which shows 3 good ways of handling images in forms.
    It also includes a PDF file with further explanation

    To use it, click the PopulateImageList button & select an image folder
    HTH
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Try:

    If Not IsNull(Me.Logo01) Then Me.LogoImage.Picture = Me.Logo01

    Yes, a form (or report) can have multiple images per record.

    An attachment field can have multiple image files.

    An expression in ControlSource can conditionally display different external files.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Null value error
    By Fionfion in forum Access
    Replies: 2
    Last Post: 10-27-2017, 11:48 AM
  2. Replies: 7
    Last Post: 02-07-2017, 05:19 PM
  3. Replies: 1
    Last Post: 12-26-2016, 08:57 AM
  4. Replies: 3
    Last Post: 07-13-2015, 12:07 PM
  5. Error displaying image on form
    By mamba716 in forum Forms
    Replies: 6
    Last Post: 06-17-2009, 09:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums