Pictures for command buttons, stored where? (1 Viewer)

Gasman

Enthusiastic Amateur
Local time
Today, 20:03
Joined
Sep 21, 2011
Messages
7,900
Hi guys,

MajP posted a nifty filter form in https://www.access-programmers.co.u...rm-filter-and-requires-almost-no-code.311279/
However in my 2007 it fails when trying to set the picture for the command button.?
Code:
          If InStr(Me.Filter, cmd.Tag) > 0 Then
            cmd.Picture = "Filter"
          Else
            cmd.Picture = "Down"
          End If
However I have discovered that I do have those pcitures in 2007, as if I select Picture from the properties I get a list as below

If I select Arrow Down, I get Down in the property, and it shows on the form.?

My question is, where are these stored so I can select as required.?

TIA

Edit: I did try "Arrow Down" as well.

1588268492628.png


1588268815954.png
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:03
Joined
Oct 29, 2018
Messages
14,577
Hi. I could be wrong, since I'll only just be guessing without seeing @MajP demo yet, but I think he may be using the Image Gallery, which you probably don't have (not in A2007). I don't think you can access those images from the Picture Builder using code. Again, I could be wrong. Cheers!
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:03
Joined
May 21, 2018
Messages
4,766
That is correct. I used the image gallery, which was a little confusing at first since it was first time using "shared" images, but allows you to reference the image by a simple name. You could roll your own with the images in the same path as the database or use simple captions ^ v (maybe some wingdings to make it look better).
image.jpg
 
Last edited:

isladogs

CID VIP
Local time
Today, 20:03
Joined
Jan 14, 2017
Messages
14,701
@Gasman
If you remember, you had problems with at least one of my apps due to the use of the image library for command button images.
For example, the use of up/down buttons in the Student Target Grade Explorer app
Any other image source works in A2007
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:03
Joined
Sep 21, 2011
Messages
7,900
Yes, I remember Colin.
I *thought* of a workaround, where I could have two buttons hidden with those pictures as their pictures and then jkust assign the picture from the relevant button?

However it still complained that it could not find the file, despite Access making it embedded.
For the Down button Access accepted and shows Down, but for the Filter button it keeps assigning (Image) no matter what icon I choose?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:03
Joined
Oct 29, 2018
Messages
14,577
Yes, I remember Colin.
I *thought* of a workaround, where I could have two buttons hidden with those pictures as their pictures and then jkust assign the picture from the relevant button?

However it still complained that it could not find the file, despite Access making it embedded.
For the Down button Access accepted and shows Down, but for the Filter button it keeps assigning (Image) no matter what icon I choose?
If it's complaining it can't find something, make sure you didn't have a typo in the names. For example, if you have something like:

Me.Button1.Picture = Me.Button2.Picture

Make sure you spelled Button1 and Button2 correctly.

Just a thought...
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:03
Joined
Sep 21, 2011
Messages
7,900
If it's complaining it can't find something, make sure you didn't have a typo in the names. For example, if you have something like:

Me.Button1.Picture = Me.Button2.Picture

Make sure you spelled Button1 and Button2 correctly.

Just a thought...
@theDBguy No, I use Intellisense. It complains it cannot find the file "(image)", so it is finding the button.

Code:
    If cmd.ControlType = acCommandButton Then
      If cmd.Tag <> "" Then
          If InStr(Me.Filter, cmd.Tag) > 0 Then
            cmd.Picture = Me.cmdFilterPic.Picture
          Else
            cmd.Picture = Me.cmdDownPic.Picture
          End If
       End If
    End If

I can go and get some tailored icons, just thought it would be nice to use the builtin ones from Access.?

It is not as if I have to distibute the DB to anyone.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:03
Joined
May 21, 2018
Messages
4,766
@Gasman
This code will allow you to download embedded images. So if you want the Access images load them into a form or control
Code:
Public Function savePictInForm(frm As Access.Form)
    Dim fname As String 'The name of the file to save the picture to
    Dim pngImage As String 'Stores the image data as a string
    Dim iFileNum As Double
    
    fname = CurrentProject.Path & "\Temp.png"
  
    iFileNum = FreeFile 'The next free file from the file systemc
    pngImage = StrConv(frm.PictureData, vbUnicode) 'Convert the byte array to a string
    MsgBox "Saved to: " & fname
    'Writes the string to the file
    Open fname For Binary Access Write As iFileNum
        Put #iFileNum, , pngImage
    Close #iFileNum
End Function
Public Function savePictInControl(ctrl As Access.Control)
    Dim filename As String 'The name of the file to save the picture to
    Dim strImage As String 'Stores the image data as a string
    Dim iFileNum As Double
    Dim realName As String
    realName = ctrl.Picture
    filename = CurrentProject.Path & "\" & realName
  
    iFileNum = FreeFile 'The next free file from the file systemc
    strImage = StrConv(ctrl.PictureData, vbUnicode) 'Convert the byte array to a string
    Debug.Print pngImage
    MsgBox "Saved to: " & filename
    'Writes the string to the file
    Open filename For Binary Access Write As iFileNum
        Put #iFileNum, , strImage
    Close #iFileNum
End Function
 

Users who are viewing this thread

Top Bottom