Results 1 to 8 of 8
  1. #1
    spidge32 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2021
    Posts
    58

    Loading Image to Report based on a field in the report

    I use this code in a form to load a image from several based on the value of fldDiagName.

    Option Compare Database
    Option Explicit
    Dim srcdoc1 As String

    Private Sub Report_Load()

    If IsNull([fldDiagName].Value) Then
    srcdoc1 = DLookup("[tblBobbinDiagrams]![Diag Path & File]", "tblBobbinDiagrams", "[Bobbin Diag Type]='BLANK'")
    Else
    srcdoc1 = DLookup("[tblBobbinDiagrams]![Diag Path & File]", "tblBobbinDiagrams", "[Bobbin Diag Type]=[fldDiagName]")


    End If

    Diagram1Image.Picture = srcdoc1
    Diagram2Image.Picture = srcdoc1
    End Sub

    When the report loads I get run time error '94', Invalid Use of Null.

    Should I be put the event after the report has loaded?
    If so where?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    Put a break point at the beginning then open the report and step through the code and let us know which line causes the error.
    Please use code tags for sql and code (# on posting toolbar) and indentation to make it easier to read. That will also stop the forum software from inserting spaces where there are none.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    spidge32 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2021
    Posts
    58
    All the fields on the report are defined in a temporary table which has all the fields for the report

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Shouldn't you be concatenating flddiagname?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    spidge32 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2021
    Posts
    58
    Welshgasman, I'm very much a beginner at Access. I'm not sure what you mean by concatenating flddiagname.
    I looked at the query from which is the report source and if you click on the Diag1.image, it shows the correct image.
    I then tried by making the query create a table and used this as the report source, but again the image is not shown.
    Either way works just fine using a combo box in the entry form for the database.

  7. #7
    spidge32 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2021
    Posts
    58
    Micron, when I put break point on any part of the code the error occurs.
    I looked at the query from which is the report source and if you click on the Diag1.image, it shows the correct image.
    I then tried by making the query create a table and used this as the report source, but again the image is not shown.
    Either way works just fine using a combo box in the entry form for the database.

  8. #8
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    There was more to what I suggested
    then open the report and step through the code and let us know which line causes the error.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 6
    Last Post: 06-08-2020, 01:54 PM
  2. Replies: 1
    Last Post: 10-27-2019, 08:56 PM
  3. Replies: 11
    Last Post: 10-16-2019, 07:33 AM
  4. Replies: 1
    Last Post: 12-11-2018, 01:05 PM
  5. Replies: 6
    Last Post: 03-22-2018, 12:02 PM

Tags for this Thread

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