andyb7901
asked on
VBA - Background image positioning
Hello
I want to be able to call an image from my VBA script and have it display on the page. I have some code but I do not know if I am doing it right?
Dim backgrd As String
backgrd = Application_Paths.ScreenBc kPth + "\Logon.bmp"
'Call CreateDesktopShortcut("frm Flash")
Me.imgBack.Picture = backgrd
In order to use the backslash to find the image does it need to be in the same folder? How would I located a file that is in the same file. Within a folder I have my database and also a folder named PNG. Within that folder is a background called "background.png". Does anybody know how to navigate this??
I want to be able to call an image from my VBA script and have it display on the page. I have some code but I do not know if I am doing it right?
Dim backgrd As String
backgrd = Application_Paths.ScreenBc
'Call CreateDesktopShortcut("frm
Me.imgBack.Picture = backgrd
In order to use the backslash to find the image does it need to be in the same folder? How would I located a file that is in the same file. Within a folder I have my database and also a folder named PNG. Within that folder is a background called "background.png". Does anybody know how to navigate this??
If u want the image to be in the same folder as your mdb
u can use this instead
CurrentProject.Path
to get filename its then
CurrentProject.Path & "\Logon.bmp"
u can use this instead
CurrentProject.Path
to get filename its then
CurrentProject.Path & "\Logon.bmp"
ASKER
Whenever I hard code it I get an error on this line;
Me.imgBack.Picture = backgrd
How would I call the background image to the screen??
Me.imgBack.Picture = backgrd
How would I call the background image to the screen??
Try me.Picture instead of Me.imgBack.Picture
ASKER
that has solved that error, but it tells me object requiremed when I try to find my image through the path.
backgrd = Application_Paths.ScreenBc kPth + "C:\Documents and Settings\Andy\Desktop\Prak tisIT\PNG\ Blank_form .png"
Do you think this is the correect way to do it?
backgrd = Application_Paths.ScreenBc
Do you think this is the correect way to do it?
This is not the correct way;
You can either do
backgrd = "C:\Documents and Settings\Andy\Desktop\Prak tisIT\PNG\ Blank_form .png"
or
backgrd = Application.CurrentProject .Path & "\Blank_Form.png"
Depending if you want to set it relative to the location to the db or if the image will always be in the one spot
You can either do
backgrd = "C:\Documents and Settings\Andy\Desktop\Prak
or
backgrd = Application.CurrentProject
Depending if you want to set it relative to the location to the db or if the image will always be in the one spot
ASKER
I think it would be sensible to use the bottom piece of code. In case the images and DB are moved. However, would it be possible for me to code it as ..\..\ to come out of the folder and into a new one. Or currently I have a db and a folder named PNG's in the same folder. What I would need is to go into the PNG folder and find an address. Would that be as simple as /PNG/filename.png.
It would be as simple addressing \PNG\Filename.png - if the PNG folder is always in the db folder
ASKER
yeah they are. What would be allthe code for the image then?
Dim backgrd As String
backgrd = Application_Paths.ScreenBc kPth + "\PNG\hEADED PAPER\MainLogoncopy_newlog o"
Me.imgBack.Picture = backgrd
Would it be as simple as this?
Dim backgrd As String
backgrd = Application_Paths.ScreenBc
Me.imgBack.Picture = backgrd
Would it be as simple as this?
Yes it would be - i would note , it is best if you use & and not + when joining text fields
ASKER
I have done the following but I keep getting the error object required(***). Im pretty sure the path is correct. I placed an image on the page using the irght click and properties command, and then browsing the file. I then copied the files path, and inserted it into my path in my code. So I think it is right?? Any ideas?
Dim backgrd As String
'on load maxmise this form
DoCmd.Maximize
****backgrd = Application_Paths.ScreenBc kPth & "\PNG\hEADED PAPER\MainLogon copy_new Logo.png"
Me.Picture = backgrd
Me.admin.Visible = False
Me.continue.Visible = False
Me.Picture = backgrd
Dim backgrd As String
'on load maxmise this form
DoCmd.Maximize
****backgrd = Application_Paths.ScreenBc
Me.Picture = backgrd
Me.admin.Visible = False
Me.continue.Visible = False
Me.Picture = backgrd
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah that seems to work now, Thanks!! Do you know why the image is displaying dead centre though. Can the window being opened only be the size of the image? Itsd just that I have spaces in the background image where things like buttons and text boxes need to go?
andyb7901, I went away to a meeting so I didnt get a chance to help you further on this
But Raynard7 sorted u out
But just wondering, did u not see my post where I mentioned using CurrentProject.Path? though I used logon.bmp as per your example code
But Raynard7 sorted u out
But just wondering, did u not see my post where I mentioned using CurrentProject.Path? though I used logon.bmp as per your example code
ASKER
Im sorry, I did not see your answer. However, Raynard did provide me with a great deal of help, and pointed out other areas to.
You can hard code it ie - C:\temp\background.png or you can use a relative location