Results 1 to 15 of 15
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Using picture as a background in a form

    Right now, I have a picture embedded into a form as it's background. I have other pictures that I've used IMG fields to use pictures from the server so that I don't use up unneeded room on my database. Is there a way to do the same for a background in a form?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Yes, on the form property sheet change picture type property from embedded to linked, navigate to a picture from the picture property, choose an image and set the other properties as required.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I changed it from embedded to linked in picture type. I'm not sure where to picture property is. The line just below picture type is picture. I tried entering the path: =DLookup("PMSDImages","tblSystemDefaults") & (DLookup("MenuBackground","tblSystemDefaults")). However, it gives me an error saying that it cannot open the file with that path.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    That's called the property sheet because every line is a property - even on a tab that's titled "event" (those are event properties). So "picture" is the picture property. When you click on the picture property line you should see ... and a drop down control. Choose the ellipses and it will open a dialog so you can navigate to the picture you want.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    That I'm able to do. I was hoping to be able to control it through my System Defaults table. I didn't want to have to navigate it through the properties each time I wanted to change it. Any way it can be done that way?

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Where did you mention you wanted it to be dynamic? I've reviewed and still can't see that request. "System Defaults" is your table?
    You will have to set the picture property in some event - probably form Open event. Perhaps using DLookup against your table to get the path.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Yes. I would like it dynamic. Thank you. On Open sounds like it might work. How would you code it? The path would be: DLookup("PMSDImages","tblSystemDefaults") & (DLookup("MenuBackground","tblSystemDefaults"))

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Create the event from the property sheet. Enter the following between Private Sub... and End Sub:

    Dim strPath As String

    strPath = DLookup("PMSDImages", "tblSystemDefaults")
    If Not strPath = "" Then Me.Picture = strPath

    You will get the first record that satisfies the expression since you didn't provide any info about criteria for the DLookup. If a record is not found, nothing should happen.
    I couldn't tell why you provided expressions for 2 path values so I just picked one. Perhaps one is a folder path and the other the filename?
    Last edited by Micron; 05-10-2021 at 07:01 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Yes. The first is the path and the second is the name. I added them to the code, but it sent me to the debugger.
    Click image for larger version. 

Name:	Error.JPG 
Views:	15 
Size:	27.8 KB 
ID:	45203

  10. #10
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I remembered that it should be & instead of And. I got the same results.

  11. #11
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You're making me guess a lot due to lack of information . Yes, it is &, not And.

    Put a break on your code on the If Not line. When it stops there, mouse over strPath and see what it shows and fix accordingly. Did you remember to include a trailing slash at the end of your first part in your table? If not, you need to concatenate it in code or add it to the field value.

    Alternatively, add this before If Not... and check the output in the immediate window to check your path.
    Debug.Print strPath
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #12
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    PMFJI,

    Quote Originally Posted by UT227 View Post
    .<snip>I was hoping to be able to control it through my System Defaults table. I didn't want to have to navigate it through the properties each time I wanted to change it. <snip>
    -- So how many pictures do you have in "tblSystemDefaults"?
    -- What is the design of the table? It looks like there are at least 2, maybe 3 fields: an unique number field, "PMSDImages" (the path to the image) and "MenuBackground" (the image name) .
    -- How are you going to pick an image? DLookup will always pick the first record if no criteria is provided (you aren't using any criteria that I can see); using the criteria option, you could generate a different number each time the dB is opened to have a different background.


    Just curious where you are headed.....

  13. #13
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    It doesn't seem to be getting to If Not.... I tried the Debug.Print.strPath. I'm not sure how to put a break in the code. Yes, the path in my System Defaults table has a trailing slash. My System Defaults table has only one record. It has 3 images.

  14. #14
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I figured out the break. It said, strPath = ""

  15. #15
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I'm not sure what happened. Maybe I was misspelling something. I rewrote it and it's working now. Thank you.

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

Similar Threads

  1. Replies: 19
    Last Post: 05-23-2020, 05:07 PM
  2. Replies: 5
    Last Post: 08-25-2018, 04:55 PM
  3. Replies: 8
    Last Post: 12-17-2017, 12:33 PM
  4. Form's Background
    By GraeagleBill in forum Forms
    Replies: 4
    Last Post: 07-07-2017, 05:33 PM
  5. Replies: 1
    Last Post: 07-03-2017, 01:49 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