A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Adding an image to a form in run time



 
 
Thread Tools Display Modes
  #1  
Old April 27th, 2010, 02:09 PM posted to microsoft.public.access.forms
vinceg
external usenet poster
 
Posts: 7
Default Adding an image to a form in run time

I have an application which enables the user to enter the parameters of a new
project, which will help size the project and estimate a cost. As part of the
application, I want to add an image of the finished product.

I've ried every combinatin of controls: image, bound & unbound objects, but
have not found the solution.

The ideal situation would be to have a default image on the form, with a
button that would trigger code to allow the user to browse for a different
picture, and replace the original. It could be a link relationship to the
picture, but the application is not very large, so the images could be
embedded.

Any help is appreciated.

Thanks,
vinceg.
--
vinceg
  #2  
Old April 27th, 2010, 04:34 PM posted to microsoft.public.access.forms
Arvin Meyer [MVP][_2_]
external usenet poster
 
Posts: 2,310
Default Adding an image to a form in run time

Use an image control. In your button's code, use:

Me.ImageControlname.Picture = "C:\PathToNew\Pic.jpg"

It's that simple.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access


"vinceg" wrote in message
...
I have an application which enables the user to enter the parameters of a
new
project, which will help size the project and estimate a cost. As part of
the
application, I want to add an image of the finished product.

I've ried every combinatin of controls: image, bound & unbound objects,
but
have not found the solution.

The ideal situation would be to have a default image on the form, with a
button that would trigger code to allow the user to browse for a different
picture, and replace the original. It could be a link relationship to the
picture, but the application is not very large, so the images could be
embedded.

Any help is appreciated.

Thanks,
vinceg.
--
vinceg



  #3  
Old April 27th, 2010, 05:21 PM posted to microsoft.public.access.forms
vinceg
external usenet poster
 
Posts: 7
Default Adding an image to a form in run time

Arvin,
Thanks for the quick response.
The problem is I do not know the path to the image at design time.
Actually, the pictures haven't been taken yet.
I want the users to be able to click a button and have a browse dialog box
apper that will allow them to select the appropriate image to be placed in
the control.
Thanks again,
vince g
--
vinceg


"Arvin Meyer [MVP]" wrote:

Use an image control. In your button's code, use:

Me.ImageControlname.Picture = "C:\PathToNew\Pic.jpg"

It's that simple.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access


"vinceg" wrote in message
...
I have an application which enables the user to enter the parameters of a
new
project, which will help size the project and estimate a cost. As part of
the
application, I want to add an image of the finished product.

I've ried every combinatin of controls: image, bound & unbound objects,
but
have not found the solution.

The ideal situation would be to have a default image on the form, with a
button that would trigger code to allow the user to browse for a different
picture, and replace the original. It could be a link relationship to the
picture, but the application is not very large, so the images could be
embedded.

Any help is appreciated.

Thanks,
vinceg.
--
vinceg



.

  #4  
Old April 28th, 2010, 11:42 AM posted to microsoft.public.access.forms
vinceg
external usenet poster
 
Posts: 7
Default Adding an image to a form in run time

Arvin,
Do you have any additional information on this issue, beyond
your initial response?
As I mentioned in my last post, I am looking for a way to
allow users to bring up a dialog box using a button on the form to
browse their files for the picture.
The pictures I want to add to the image control would be
retrieved from the user's file system (C:/userfolder/).
Thanks again,
--
vinceg


"Arvin Meyer [MVP]" wrote:

Use an image control. In your button's code, use:

Me.ImageControlname.Picture = "C:\PathToNew\Pic.jpg"

It's that simple.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access


"vinceg" wrote in message
...
I have an application which enables the user to enter the parameters of a
new
project, which will help size the project and estimate a cost. As part of
the
application, I want to add an image of the finished product.

I've ried every combinatin of controls: image, bound & unbound objects,
but
have not found the solution.

The ideal situation would be to have a default image on the form, with a
button that would trigger code to allow the user to browse for a different
picture, and replace the original. It could be a link relationship to the
picture, but the application is not very large, so the images could be
embedded.

Any help is appreciated.

Thanks,
vinceg.
--
vinceg



.

  #5  
Old April 28th, 2010, 03:06 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Adding an image to a form in run time

Use the code in http://www.mvps.org/access/api/api0001.htm at "The Access
Web" to bring up the Windows File Open dialog box to allow them to select
the file.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"vinceg" wrote in message
...
Arvin,
Do you have any additional information on this issue, beyond
your initial response?
As I mentioned in my last post, I am looking for a way to
allow users to bring up a dialog box using a button on the form to
browse their files for the picture.
The pictures I want to add to the image control would be
retrieved from the user's file system (C:/userfolder/).
Thanks again,
--
vinceg


"Arvin Meyer [MVP]" wrote:

Use an image control. In your button's code, use:

Me.ImageControlname.Picture = "C:\PathToNew\Pic.jpg"

It's that simple.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access


"vinceg" wrote in message
...
I have an application which enables the user to enter the parameters of
a
new
project, which will help size the project and estimate a cost. As part
of
the
application, I want to add an image of the finished product.

I've ried every combinatin of controls: image, bound & unbound objects,
but
have not found the solution.

The ideal situation would be to have a default image on the form, with
a
button that would trigger code to allow the user to browse for a
different
picture, and replace the original. It could be a link relationship to
the
picture, but the application is not very large, so the images could be
embedded.

Any help is appreciated.

Thanks,
vinceg.
--
vinceg



.


  #6  
Old April 28th, 2010, 08:36 PM posted to microsoft.public.access.forms
vinceg
external usenet poster
 
Posts: 7
Default Adding an image to a form in run time

Doug,
Thank you for the response.
I'm not an expert coder......
I pasted the code into a new function from the site you mentioned,
and called the function from a command button:
"----
Function TestIt()
Dim strFilter As String
Dim lngFlags As Long
strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
"*.MDA;*.MDB")
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

' Uncomment this line to try the example
' allowing multiple file names:
' lngFlags = ahtOFN_ALLOWMULTISELECT Or ahtOFN_EXPLORER

Dim result As Variant

result = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")

If lngFlags And ahtOFN_ALLOWMULTISELECT Then
If IsArray(result) Then
Dim i As Integer
For i = 0 To UBound(result)
MsgBox result(i)
Next i
Else
MsgBox result
End If
Else
MsgBox result
End If

' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
End Function
-- "
Got "Sub or Function not defined" error for "ahtAddFilterItem"....

Have no idea what to do with this message.....

This may be way beyond my level of coding expertise, but I can't believe
there isn't
a run-time control that that works the same as the design time control when
you want to embed an file into an image.

I looked in MS for info on this, but don't know where to start.
I could use some help that acknowledges my relatively low level of technical
experience.
Thanks,
vinceg


"Douglas J. Steele" wrote:

Use the code in http://www.mvps.org/access/api/api0001.htm at "The Access
Web" to bring up the Windows File Open dialog box to allow them to select
the file.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"vinceg" wrote in message
...
Arvin,
Do you have any additional information on this issue, beyond
your initial response?
As I mentioned in my last post, I am looking for a way to
allow users to bring up a dialog box using a button on the form to
browse their files for the picture.
The pictures I want to add to the image control would be
retrieved from the user's file system (C:/userfolder/).
Thanks again,
--
vinceg


"Arvin Meyer [MVP]" wrote:

Use an image control. In your button's code, use:

Me.ImageControlname.Picture = "C:\PathToNew\Pic.jpg"

It's that simple.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access


"vinceg" wrote in message
...
I have an application which enables the user to enter the parameters of
a
new
project, which will help size the project and estimate a cost. As part
of
the
application, I want to add an image of the finished product.

I've ried every combinatin of controls: image, bound & unbound objects,
but
have not found the solution.

The ideal situation would be to have a default image on the form, with
a
button that would trigger code to allow the user to browse for a
different
picture, and replace the original. It could be a link relationship to
the
picture, but the application is not very large, so the images could be
embedded.

Any help is appreciated.

Thanks,
vinceg.
--
vinceg


.


.

  #7  
Old April 28th, 2010, 08:52 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Adding an image to a form in run time

Did you paste all of the code? ahtAddFilterItem is a function toward the
bottom of the web page link that Douglas provided. Be sure to compile the
code (Debug Compile) after you paste it into your code module.

vinceg wrote:
Doug,
Thank you for the response.
I'm not an expert coder......
I pasted the code into a new function from the site you mentioned,
and called the function from a command button:
"----
Function TestIt()
Dim strFilter As String
Dim lngFlags As Long
strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
"*.MDA;*.MDB")
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

' Uncomment this line to try the example
' allowing multiple file names:
' lngFlags = ahtOFN_ALLOWMULTISELECT Or ahtOFN_EXPLORER

Dim result As Variant

result = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")

If lngFlags And ahtOFN_ALLOWMULTISELECT Then
If IsArray(result) Then
Dim i As Integer
For i = 0 To UBound(result)
MsgBox result(i)
Next i
Else
MsgBox result
End If
Else
MsgBox result
End If

' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
End Function
-- "
Got "Sub or Function not defined" error for "ahtAddFilterItem"....

Have no idea what to do with this message.....

This may be way beyond my level of coding expertise, but I can't believe
there isn't
a run-time control that that works the same as the design time control when
you want to embed an file into an image.

I looked in MS for info on this, but don't know where to start.
I could use some help that acknowledges my relatively low level of technical
experience.
Thanks,
vinceg

Use the code in http://www.mvps.org/access/api/api0001.htm at "The Access
Web" to bring up the Windows File Open dialog box to allow them to select

[quoted text clipped - 44 lines]

.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201004/1

  #8  
Old April 28th, 2010, 09:17 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Adding an image to a form in run time

Also, make sure that the name of the module is unique: you'll run into
problems if the module has the same name as a function or sub anywhere in
the application.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"BruceM via AccessMonster.com" u54429@uwe wrote in message
news:a73868a71bcf6@uwe...
Did you paste all of the code? ahtAddFilterItem is a function toward the
bottom of the web page link that Douglas provided. Be sure to compile the
code (Debug Compile) after you paste it into your code module.

vinceg wrote:
Doug,
Thank you for the response.
I'm not an expert coder......
I pasted the code into a new function from the site you mentioned,
and called the function from a command button:
"----
Function TestIt()
Dim strFilter As String
Dim lngFlags As Long
strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)",
_
"*.MDA;*.MDB")
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)",
"*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

' Uncomment this line to try the example
' allowing multiple file names:
' lngFlags = ahtOFN_ALLOWMULTISELECT Or ahtOFN_EXPLORER

Dim result As Variant

result = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")

If lngFlags And ahtOFN_ALLOWMULTISELECT Then
If IsArray(result) Then
Dim i As Integer
For i = 0 To UBound(result)
MsgBox result(i)
Next i
Else
MsgBox result
End If
Else
MsgBox result
End If

' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
End Function
-- "
Got "Sub or Function not defined" error for "ahtAddFilterItem"....

Have no idea what to do with this message.....

This may be way beyond my level of coding expertise, but I can't believe
there isn't
a run-time control that that works the same as the design time control
when
you want to embed an file into an image.

I looked in MS for info on this, but don't know where to start.
I could use some help that acknowledges my relatively low level of
technical
experience.
Thanks,
vinceg

Use the code in http://www.mvps.org/access/api/api0001.htm at "The
Access
Web" to bring up the Windows File Open dialog box to allow them to
select

[quoted text clipped - 44 lines]

.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201004/1


  #9  
Old April 28th, 2010, 09:24 PM posted to microsoft.public.access.forms
Max_D via AccessMonster.com
external usenet poster
 
Posts: 2
Default Adding an image to a form in run time

There is the component called AccessImagine, that makes inserting images in
Access database an easy task - users can browse, paste, scan or drag-n-drop
images right to database.

In fact, it can handle all the imaging tasks without any programming.

--
"Be aware of WordPress, it provokes to write bloggy-style..." (c) Gunna

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201004/1

  #10  
Old April 28th, 2010, 10:38 PM posted to microsoft.public.access.forms
vinceg
external usenet poster
 
Posts: 7
Default Adding an image to a form in run time

Bruce,
Thanks for the reply.
Once I pasted all the code it workedas intended.
I got the name & path of the file I want displayed on a message box.

In the Click event Sub, I used 'result' ( the name dim'ed in the code) as
follows:
( Me.Image140.Picture = result ), and saved the form.
Pressing the button yielded the message box, but after pressing OK in the
message box, nothing appeared in the image control.
Is that the correct syntax for the image control?
I'm getting closer to understanding the way this works under the forms.
It's quite an education.... thanks.
--
vinceg


"BruceM via AccessMonster.com" wrote:

Did you paste all of the code? ahtAddFilterItem is a function toward the
bottom of the web page link that Douglas provided. Be sure to compile the
code (Debug Compile) after you paste it into your code module.

vinceg wrote:
Doug,
Thank you for the response.
I'm not an expert coder......
I pasted the code into a new function from the site you mentioned,
and called the function from a command button:
"----
Function TestIt()
Dim strFilter As String
Dim lngFlags As Long
strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
"*.MDA;*.MDB")
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

' Uncomment this line to try the example
' allowing multiple file names:
' lngFlags = ahtOFN_ALLOWMULTISELECT Or ahtOFN_EXPLORER

Dim result As Variant

result = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")

If lngFlags And ahtOFN_ALLOWMULTISELECT Then
If IsArray(result) Then
Dim i As Integer
For i = 0 To UBound(result)
MsgBox result(i)
Next i
Else
MsgBox result
End If
Else
MsgBox result
End If

' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
End Function
-- "
Got "Sub or Function not defined" error for "ahtAddFilterItem"....

Have no idea what to do with this message.....

This may be way beyond my level of coding expertise, but I can't believe
there isn't
a run-time control that that works the same as the design time control when
you want to embed an file into an image.

I looked in MS for info on this, but don't know where to start.
I could use some help that acknowledges my relatively low level of technical
experience.
Thanks,
vinceg

Use the code in http://www.mvps.org/access/api/api0001.htm at "The Access
Web" to bring up the Windows File Open dialog box to allow them to select

[quoted text clipped - 44 lines]

.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201004/1

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:26 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.