Using pictures on a form and report

The following question was asked in the newsgroup.

I’d like to add a picture in a report’s detail section where the path to the picture is from a table.

Incredibly easy.  The same code works on a form as well.  Using the Toolbox drop an image control on the reports detail section.   Note that you will have to follow the dialog and actually insert an image.  But then go to the Picture property on the Format tab in the property sheet and delete the actual file.  You will probably want to set the Size Mode from clip to zoom. And rename the control to something meaningful.

Then in the report detail section in the On Print event you want to add the following lines of code

    If <logic if file available to view> Then
        Me.PhotoImage.Picture = PhotoFilePath
        Me.PhotoImage.Picture = “”
    End If

PhotoFilePath being whatever logic you want to use to figure out the file that you want printed.

You don’t want to do this logic in the Format event as Microsoft has told us, via Stephen Lebans, that using that event can lead to memory leak problems.  Or you can use BMP images.   Which is rather impractical.

The reason for extensive bloating in Access when JPG or other graphic files are permanently embedded in forms or reports is that Access converts those file formats to BMP format.   This made sense back in Access 2.0 days is viewing a JPG file was very slow as it requires lots of CPU cycles.  80386 computers running Windows 3.1 were rather slow at that.  BMP format meant that you basically read the large file directly into the graphics card memory.   In Access 2007 the Access product group have updated that logic so the BMP file format isn’t created any more.

Shameless plug:  I have a number of reports in the Granite Fleet Manager which print a “primary” and a number of “secondary” photo’s for each unit.   See Granite Fleet manager Main Menu a screen shot and Service Order Details (with Photo) for a sample report.

I never knew that – view linked table file path and name

I was in the table view in Access 2003 and accidentally hovered over a linked table.  A tool tip (mouse over tip) displayed itself a second later telling me the backend linked MDB file path and name.


Cool!  I never knew that.

I should add that I go to great lengths to ensure a user doesn’t have a problem with linked tables.   When the user opens the app I ensure that all tables have the same linked path and file name.   Just in case.  You never know when something really, really weird could happen when relinking tables.   And I’d hate to have to debug a customers problem where a few tables are pointing to a demo MDB and all the other tables are pointing to their live data table.

Other things I do on start are opening a recordset based on a particular table and check for a particular field in it.  If that fails I assume the BE isn’t linked properly and start up the linking table logic.

Note that I install the Granite Fleet Manager into the users Application Data folder and  sub folder of Granite Fleet Mgr using Inno Setup.  I also install the Demo MDB and the demo graphics files into that same folder.  However the live empty Data.MDB gets installed into My Documents\Granite Fleet Mgr.

I then check to see if there is a license key file in the users My Documents\Granite Fleet Mgr folder.  If so I then look to see if there is only one data MDB file in that folder. I inform the user and ask if they want to relink to that table.  If there are two or more data MDBs then I inform them and pop up a relinking form.  This handles the situation where I’ve converted their data from a spreadsheet and emailed the user that MDB and the license key file.



Note how the number of Units and Service Orders are displayed in the list box.  I’ve found this to be of great value when working with clients and somehow multiple versions of the BE data MDB are floating about.

Thanks to Jim, a friend and client, who suggested adding the Selected Data File Folder field.  If folks are interested and understand what is all going on then that’s all the better.   That field can be double clicked and Windows Explorer opens to that folder.  The code behind that double click event for the Selected Data File Folder is:

Call RunShellExecute(tt_StripFromLastRight(CurrentDb.Name, “\”))

tt_StripFromLastRight is a function which removes the “\” and everything to the right leaving just the path.

If nothing found as per the above paragraphs then the linking table logic first examines the current FE path for the Granite Fleet Mgr.INI file. If found I then relink to the BE MDB as specified in that INI file.  This handles the situation where the app has been previously installed on the system and the INI file is pointing to a network file location.

If that file isn’t found then I assume this is the first time the user has ever run the app and link to the demo MDB.

I also display the path and file name of the BE MDB in the About screen.  As well as the current FE MDB/MDE file path and name.  


I also put in a double click event on those two fields which the user can then open up Windows Explorer.  Do you really want to tell a user how to use Windows Explorer to navigate to a path that Windows by default hides from the user?  No, I didn’t think you would either.

Still reading?   All this when all I meant to type was the first few paragraphs. <sigh>

How are your personal backups?

Including all your photos? And your Outlook and Outlook Express files which are, last I read, stored in a sub folder of your Application Data folder and not your My Documents folder?

“The GpCode family is a dangerous form of malware which can permanently destroy files by encrypting them.  The capability for AV products to de-crypt files vary and can’t be relied on in all cases, especially when complex encryption techniques are used. “

New GpCode Ransomeware attack encrypts victims files

No, no, no.  Do not leave this until tomorrow.   Grab a coffee and start copying files to a DVD.

My muddiness when it comes to OpenArgs

I was getting an syntax error message when I clicked on a New button on the Equipment Quick Finder form.  The equipment form in the Granite Fleet Manager executes a reasonable amount of code on startup. 

I had added that New button to the Quick Finder form when I created it and all was well.  Trouble is I added some code in the Equipment form that required the OpenArgs start with “New” when the record did not exist.   And now the code was causing me troubles. While I fixed the immediate problem I realized I had a larger issue.

When testing I realized that if I’m updating a piece of equipment then the OpenArgs will legitimately be empty.

So I added the following code in the forms Open Event.

     If IsNull(Me.OpenArgs) And Len(Me.Filter) = 0 Then _
         MsgBox “OpenArgs is null and Filter is empty.”

I also did a Find through all the code looking for OpenForm “Equipment” just to ensure I didn’t have any other problems hidden away somewhere else.

The lesson is that if you are depending that OpenArgs have values in it ensure that values are always present.  Pop up a message for the programmer to give him (or her) a kick.

This is a follow up to the Watch out for Null OpenArgs blog posting.   (And I sincerely hope my clients never chip in to purchase the chair mentioned at Microsoft: We Share Your Pain.)

Meteorite search update

Very interesting.  Meteorite search update  It was estimated to weigh 10 tonnes when it entered the atmosphere at 14 km/sec.  Possibly football sized chunks. 

I sure hope the local farmers aren’t troubled too much by *rsehole souvenir hunters but I know they will be.  They might as well get any cattle, horses and livestock off the fields until the snow falls.  And even then there’ll be folks out there leaving the fences open or just plain cutting the fences.  I’d like to see the scientists get the rocks first before the folks who want to sell chunks.

Microsoft Math – $20 – Wow

Microsoft Math 3.0   Wow.  3D graphing.  For 20 freaking dollars.

When I was a teenager (Yeah, yeah, some of you are clicking on the next blog entry button.) I was teaching myself WatFiv and a bit of PL/C and S/360 Assembler at the local college after school hours.  I was doing some graphing using some libraries of code which meant printing out the graphs using *+- and | on a 132 character dot matrix line printer.   I was using punched cards and did a very little bit of work on a 24×80 text screen.  No such thing as Windows or even DOS then. 

Although the Altair came out soon thereafter.  8 Kb of RAM I vaguely recall.  Or maybe it was 256 bytes of RAM.   (Ah I’m right.  According to Wiki It came with 256 bytes of RAM and you could order a 4 Kb RAM board for half the price of the initial computer.)

I was also doing some graphing with equations in high school where you had to put in the values of x and hand plot the values of y.   Took minutes for each equation.  I was thinking wouldn’t it be so neat if we could plot the graphs on a computer screen, change a value in the equation and see instantly how the graph would change.   The equations would become so much more intuitive rather than being just images in the text book or smudges of pencil on graph paper.  Remember graph paper?

And now you get 3D graphing for $20.  Wow!

(Note the reference to Microsoft at the bottom of the Altair Wiki page.)

Have software patents been thrown out?

Slashdot article – Groklaw Says Microsoft Patent Portfolio Now Worthless

If so I think that’s excellent.  Too many of the software patents we see mentioned in the software media are ridiculous and obvious.   Frequently the basics of the patent have already been done years before the application.

Of course who wouldn’t be in favour of causing trouble for the scum sucking, bottom feeding lawyers who are suing folks based on such.

And as I’m reading the Groklaw article about tax strategy patents referenced in the above article I’m shaking my head in disgust.