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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Optional image vs. OLE
I understand that using the Image control, storing the image path in a text
field, and loading the image at runtime is superior (spacewise) to using an object frame bound to an OLE field, but I have two questions: 1. Since, in my application, it is up to the user to import an image or leave it empty, how do I hold the place/size of the Image control when it has no image? Should I just provide a default image of a jpeg that says "No image selected" and insert that by default and if the user elects to remove the reference to the image? 2. What if the user moves the image file? What code could I insert in the report that includes a reference to this image to ensure that the image is simply omitted if it is not found rather than generating an error? Would this be: If Len(Dir(Stored path/filename)) = 0 Then...? |
#2
|
|||
|
|||
The answser to both questions is yes. Additionally, putting the images on a
network drive will lessen the chance of the user moving them. -- Arvin Meyer, MCP, MVP Microsoft Access Free Access downloads: http://www.datastrat.com http://www.mvps.org/access "Brian" wrote in message ... I understand that using the Image control, storing the image path in a text field, and loading the image at runtime is superior (spacewise) to using an object frame bound to an OLE field, but I have two questions: 1. Since, in my application, it is up to the user to import an image or leave it empty, how do I hold the place/size of the Image control when it has no image? Should I just provide a default image of a jpeg that says "No image selected" and insert that by default and if the user elects to remove the reference to the image? 2. What if the user moves the image file? What code could I insert in the report that includes a reference to this image to ensure that the image is simply omitted if it is not found rather than generating an error? Would this be: If Len(Dir(Stored path/filename)) = 0 Then...? |
#3
|
|||
|
|||
I did both of these, but since this is an app that I am distributing to
clients form whom I do not provide any infrastructure support, I cannot guarantee that the default file will be or stay in the default location, nor even that their default location will be the same (assuming it will be on a mapped drive). Certainly, my help files will indicate that the image files should be placed on the server so that they are accessible by the user regardless of which workstation he chooses to use (assuming the drive mapping is consistent). The table that contains the user profile has a field for the path/filename to that user's image file, but the entry will be null by default and will only be populated if the user browses for selects an image file (using the comdlg32 API call). On the open event of the user options form, I set the image control's ..Picture property to the filepath string from the current user's profile in the table (if the pathname has been set). However, I still had to hard-code the .Picture property when saving the form, because the Image control will not remain on the form without a valid image path. I was hoping that there would be a way embed the default image in the database so that I could have the Image control load that one if the user does not have one. However, it appears that the .Picture property can only be a reference to an external image file, not to an image file embedded in the database. I did make a workaround for those cases when neither the user's image file or the default cannot be found (but I just don't like workarounds, and I may not be foreseeing the time when someone manages to do something that actually removes the control from the form because there is no valid image file found): -Trap & ignore the 2220 error that occurs in this case -If the user has no image file in his profile, and if the default image file is not found at the hard-coded location, do the following two things: -Set the image control's .Visible property to False -Overlay a text box (containing a note about how to link to an image file) over the image control, and set its .Visible property to True If a valid image file is found, vice versa both of the above. If I am just making this too difficult, please let me know of an easier way. I'm trying to prevent the "Just get MS Photo Editor off your Office 2000 disk" fix that I might have to try to sell to the client if I go with OLE, as well as the file bloat that occurs from embedding pictures. "Arvin Meyer [MVP]" wrote: The answser to both questions is yes. Additionally, putting the images on a network drive will lessen the chance of the user moving them. -- Arvin Meyer, MCP, MVP Microsoft Access Free Access downloads: http://www.datastrat.com http://www.mvps.org/access "Brian" wrote in message ... I understand that using the Image control, storing the image path in a text field, and loading the image at runtime is superior (spacewise) to using an object frame bound to an OLE field, but I have two questions: 1. Since, in my application, it is up to the user to import an image or leave it empty, how do I hold the place/size of the Image control when it has no image? Should I just provide a default image of a jpeg that says "No image selected" and insert that by default and if the user elects to remove the reference to the image? 2. What if the user moves the image file? What code could I insert in the report that includes a reference to this image to ensure that the image is simply omitted if it is not found rather than generating an error? Would this be: If Len(Dir(Stored path/filename)) = 0 Then...? |
#4
|
|||
|
|||
A couple of methods are available:
1) Add a hidden Image control to the form in question. Load your "default Picture" into this control. Your statement is incorrect that the Image control cannot contain an Image without a valid/existing path. In design view, once you select an Image via the control's Picture property, it remains embedded. Now whenever you want to display the defaul pic simply do something like: Me.ThisFormsImageControl.PictureData = Forms!NameOFtheHiddenForm.ImageControl.PictureData or 2) Load the default pic into an Image control. Copy the control's PictureData property to a table containing a Long Binary field When you want to display the default pic simply copy the contents of the field to the PictureData prop of the desired Image control. -- HTH Stephen Lebans http://www.lebans.com Access Code, Tips and Tricks Please respond only to the newsgroups so everyone can benefit. "Brian" wrote in message ... I did both of these, but since this is an app that I am distributing to clients form whom I do not provide any infrastructure support, I cannot guarantee that the default file will be or stay in the default location, nor even that their default location will be the same (assuming it will be on a mapped drive). Certainly, my help files will indicate that the image files should be placed on the server so that they are accessible by the user regardless of which workstation he chooses to use (assuming the drive mapping is consistent). The table that contains the user profile has a field for the path/filename to that user's image file, but the entry will be null by default and will only be populated if the user browses for selects an image file (using the comdlg32 API call). On the open event of the user options form, I set the image control's .Picture property to the filepath string from the current user's profile in the table (if the pathname has been set). However, I still had to hard-code the .Picture property when saving the form, because the Image control will not remain on the form without a valid image path. I was hoping that there would be a way embed the default image in the database so that I could have the Image control load that one if the user does not have one. However, it appears that the .Picture property can only be a reference to an external image file, not to an image file embedded in the database. I did make a workaround for those cases when neither the user's image file or the default cannot be found (but I just don't like workarounds, and I may not be foreseeing the time when someone manages to do something that actually removes the control from the form because there is no valid image file found): -Trap & ignore the 2220 error that occurs in this case -If the user has no image file in his profile, and if the default image file is not found at the hard-coded location, do the following two things: -Set the image control's .Visible property to False -Overlay a text box (containing a note about how to link to an image file) over the image control, and set its .Visible property to True If a valid image file is found, vice versa both of the above. If I am just making this too difficult, please let me know of an easier way. I'm trying to prevent the "Just get MS Photo Editor off your Office 2000 disk" fix that I might have to try to sell to the client if I go with OLE, as well as the file bloat that occurs from embedding pictures. "Arvin Meyer [MVP]" wrote: The answser to both questions is yes. Additionally, putting the images on a network drive will lessen the chance of the user moving them. -- Arvin Meyer, MCP, MVP Microsoft Access Free Access downloads: http://www.datastrat.com http://www.mvps.org/access "Brian" wrote in message ... I understand that using the Image control, storing the image path in a text field, and loading the image at runtime is superior (spacewise) to using an object frame bound to an OLE field, but I have two questions: 1. Since, in my application, it is up to the user to import an image or leave it empty, how do I hold the place/size of the Image control when it has no image? Should I just provide a default image of a jpeg that says "No image selected" and insert that by default and if the user elects to remove the reference to the image? 2. What if the user moves the image file? What code could I insert in the report that includes a reference to this image to ensure that the image is simply omitted if it is not found rather than generating an error? Would this be: If Len(Dir(Stored path/filename)) = 0 Then...? |
#5
|
|||
|
|||
Thank you, Stephen. What I meant is that one cannot remove/nullify the
..Picture property because Access assumes that you are trying to remove the control (and rightly so, I guess, since it is, after all, an image). I noticed that once set to a valid path it is persistent, even if the file is later removed. By either trapping the 2220 error or doing On Error Resume Next, I can get past the error that is generated if it is linked but the file is not found. Every time I drop into design view, however, I get a message indicating that Access could not open the file. That is a minor nuisance, though. I assume in your #1 that you mean to embed the image in the hidden control so that it is available for the other one. Is either of these two options more efficient than the other? "Stephen Lebans" wrote: A couple of methods are available: 1) Add a hidden Image control to the form in question. Load your "default Picture" into this control. Your statement is incorrect that the Image control cannot contain an Image without a valid/existing path. In design view, once you select an Image via the control's Picture property, it remains embedded. Now whenever you want to display the defaul pic simply do something like: Me.ThisFormsImageControl.PictureData = Forms!NameOFtheHiddenForm.ImageControl.PictureData or 2) Load the default pic into an Image control. Copy the control's PictureData property to a table containing a Long Binary field When you want to display the default pic simply copy the contents of the field to the PictureData prop of the desired Image control. -- HTH Stephen Lebans http://www.lebans.com Access Code, Tips and Tricks Please respond only to the newsgroups so everyone can benefit. "Brian" wrote in message ... I did both of these, but since this is an app that I am distributing to clients form whom I do not provide any infrastructure support, I cannot guarantee that the default file will be or stay in the default location, nor even that their default location will be the same (assuming it will be on a mapped drive). Certainly, my help files will indicate that the image files should be placed on the server so that they are accessible by the user regardless of which workstation he chooses to use (assuming the drive mapping is consistent). The table that contains the user profile has a field for the path/filename to that user's image file, but the entry will be null by default and will only be populated if the user browses for selects an image file (using the comdlg32 API call). On the open event of the user options form, I set the image control's .Picture property to the filepath string from the current user's profile in the table (if the pathname has been set). However, I still had to hard-code the .Picture property when saving the form, because the Image control will not remain on the form without a valid image path. I was hoping that there would be a way embed the default image in the database so that I could have the Image control load that one if the user does not have one. However, it appears that the .Picture property can only be a reference to an external image file, not to an image file embedded in the database. I did make a workaround for those cases when neither the user's image file or the default cannot be found (but I just don't like workarounds, and I may not be foreseeing the time when someone manages to do something that actually removes the control from the form because there is no valid image file found): -Trap & ignore the 2220 error that occurs in this case -If the user has no image file in his profile, and if the default image file is not found at the hard-coded location, do the following two things: -Set the image control's .Visible property to False -Overlay a text box (containing a note about how to link to an image file) over the image control, and set its .Visible property to True If a valid image file is found, vice versa both of the above. If I am just making this too difficult, please let me know of an easier way. I'm trying to prevent the "Just get MS Photo Editor off your Office 2000 disk" fix that I might have to try to sell to the client if I go with OLE, as well as the file bloat that occurs from embedding pictures. "Arvin Meyer [MVP]" wrote: The answser to both questions is yes. Additionally, putting the images on a network drive will lessen the chance of the user moving them. -- Arvin Meyer, MCP, MVP Microsoft Access Free Access downloads: http://www.datastrat.com http://www.mvps.org/access "Brian" wrote in message ... I understand that using the Image control, storing the image path in a text field, and loading the image at runtime is superior (spacewise) to using an object frame bound to an OLE field, but I have two questions: 1. Since, in my application, it is up to the user to import an image or leave it empty, how do I hold the place/size of the Image control when it has no image? Should I just provide a default image of a jpeg that says "No image selected" and insert that by default and if the user elects to remove the reference to the image? 2. What if the user moves the image file? What code could I insert in the report that includes a reference to this image to ensure that the image is simply omitted if it is not found rather than generating an error? Would this be: If Len(Dir(Stored path/filename)) = 0 Then...? |
#6
|
|||
|
|||
I would use the hidden Image control method.
-- HTH Stephen Lebans http://www.lebans.com Access Code, Tips and Tricks Please respond only to the newsgroups so everyone can benefit. "Brian" wrote in message ... Thank you, Stephen. What I meant is that one cannot remove/nullify the .Picture property because Access assumes that you are trying to remove the control (and rightly so, I guess, since it is, after all, an image). I noticed that once set to a valid path it is persistent, even if the file is later removed. By either trapping the 2220 error or doing On Error Resume Next, I can get past the error that is generated if it is linked but the file is not found. Every time I drop into design view, however, I get a message indicating that Access could not open the file. That is a minor nuisance, though. I assume in your #1 that you mean to embed the image in the hidden control so that it is available for the other one. Is either of these two options more efficient than the other? "Stephen Lebans" wrote: A couple of methods are available: 1) Add a hidden Image control to the form in question. Load your "default Picture" into this control. Your statement is incorrect that the Image control cannot contain an Image without a valid/existing path. In design view, once you select an Image via the control's Picture property, it remains embedded. Now whenever you want to display the defaul pic simply do something like: Me.ThisFormsImageControl.PictureData = Forms!NameOFtheHiddenForm.ImageControl.PictureData or 2) Load the default pic into an Image control. Copy the control's PictureData property to a table containing a Long Binary field When you want to display the default pic simply copy the contents of the field to the PictureData prop of the desired Image control. -- HTH Stephen Lebans http://www.lebans.com Access Code, Tips and Tricks Please respond only to the newsgroups so everyone can benefit. "Brian" wrote in message ... I did both of these, but since this is an app that I am distributing to clients form whom I do not provide any infrastructure support, I cannot guarantee that the default file will be or stay in the default location, nor even that their default location will be the same (assuming it will be on a mapped drive). Certainly, my help files will indicate that the image files should be placed on the server so that they are accessible by the user regardless of which workstation he chooses to use (assuming the drive mapping is consistent). The table that contains the user profile has a field for the path/filename to that user's image file, but the entry will be null by default and will only be populated if the user browses for selects an image file (using the comdlg32 API call). On the open event of the user options form, I set the image control's .Picture property to the filepath string from the current user's profile in the table (if the pathname has been set). However, I still had to hard-code the .Picture property when saving the form, because the Image control will not remain on the form without a valid image path. I was hoping that there would be a way embed the default image in the database so that I could have the Image control load that one if the user does not have one. However, it appears that the .Picture property can only be a reference to an external image file, not to an image file embedded in the database. I did make a workaround for those cases when neither the user's image file or the default cannot be found (but I just don't like workarounds, and I may not be foreseeing the time when someone manages to do something that actually removes the control from the form because there is no valid image file found): -Trap & ignore the 2220 error that occurs in this case -If the user has no image file in his profile, and if the default image file is not found at the hard-coded location, do the following two things: -Set the image control's .Visible property to False -Overlay a text box (containing a note about how to link to an image file) over the image control, and set its .Visible property to True If a valid image file is found, vice versa both of the above. If I am just making this too difficult, please let me know of an easier way. I'm trying to prevent the "Just get MS Photo Editor off your Office 2000 disk" fix that I might have to try to sell to the client if I go with OLE, as well as the file bloat that occurs from embedding pictures. "Arvin Meyer [MVP]" wrote: The answser to both questions is yes. Additionally, putting the images on a network drive will lessen the chance of the user moving them. -- Arvin Meyer, MCP, MVP Microsoft Access Free Access downloads: http://www.datastrat.com http://www.mvps.org/access "Brian" wrote in message ... I understand that using the Image control, storing the image path in a text field, and loading the image at runtime is superior (spacewise) to using an object frame bound to an OLE field, but I have two questions: 1. Since, in my application, it is up to the user to import an image or leave it empty, how do I hold the place/size of the Image control when it has no image? Should I just provide a default image of a jpeg that says "No image selected" and insert that by default and if the user elects to remove the reference to the image? 2. What if the user moves the image file? What code could I insert in the report that includes a reference to this image to ensure that the image is simply omitted if it is not found rather than generating an error? Would this be: If Len(Dir(Stored path/filename)) = 0 Then...? |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Load image crashes | SteveWalker | Using Forms | 2 | September 20th, 2005 04:55 PM |
Linking v Embedded | Jim Bunton | General Discussion | 5 | August 10th, 2005 11:09 PM |
Odd behavior on margin change | John | Charts and Charting | 2 | June 20th, 2005 02:03 PM |
How do I Get a OLE Image into a field from another table? | Paul | Using Forms | 0 | November 25th, 2004 03:15 AM |
Electronic Price List | Jono | General Discussion | 2 | September 28th, 2004 03:59 PM |