473,396 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Inserting Pictures into Command Button from a Table

Hi All
Ive got an issue with inserting images into a command button from a table that I have embedded a OLE object into. The following is the code Im am trying to use;

Expand|Select|Wrap|Line Numbers
  1. If bolMenuVisible Then
  2.                     Me("Option" & rst![ItemNumber]).Visible = True
  3.    '                 Me("Option" & rst![ItemNumber]).Picture = rst![Icon]            ' icon
  4.           '          Me("Option" & rst![ItemNumber]).PictureData = cmd1.PictureData  ' icon
  5.                     Me("Option" & rst![ItemNumber]).PictureData = DLookup("IImage", "tblImage") ' icon
  6.                     Me("OptionLabel" & rst![ItemNumber]).Visible = True
  7.                     Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
  8.  
  9.             Else
  10.                 If (rst![ItemNumber] < 7) Or (rst![ItemNumber] > 9) Then
  11.   '                  Me("Option" & rst![ItemNumber]).Picture = rst![Icon]            ' icon
  12.    '                 Me("Option" & rst![ItemNumber]).PictureData = cmd1.PictureData  ' icon
  13.                     Me("Option" & rst![ItemNumber]).PictureData = DLookup("IImage", "tblImage") ' icon
  14.                    Me("Option" & rst![ItemNumber]).Visible = True
  15.                     Me("OptionLabel" & rst![ItemNumber]).Visible = True
  16.                     Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
  17.                 End If
  18.             End If
  19.  
However, this returns an error that the image is not a device independant bitmap (which it is). Any ideas?
Feb 5 '07 #1
5 3898
MMcCarthy
14,534 Expert Mod 8TB
Try this ...

Expand|Select|Wrap|Line Numbers
  1. If bolMenuVisible Then
  2.   Me("Option" & rst![ItemNumber]).Visible = True
  3.   Me("Option" & rst![ItemNumber]).Picture = "'" & rst![Icon] & "'"
  4.   Me("OptionLabel" & rst![ItemNumber]).Visible = True
  5.   Me("OptionLabel" & rst![ItemNumber]).Caption = "'" & rst![ItemText] & "'"
  6. Else
  7.   If (rst![ItemNumber] < 7) Or (rst![ItemNumber] > 9) Then
  8.     Me("Option" & rst![ItemNumber]).Picture = "'" & rst![Icon] & "'"
  9.     Me("Option" & rst![ItemNumber]).Visible = True
  10.     Me("OptionLabel" & rst![ItemNumber]).Visible = True
  11.     Me("OptionLabel" & rst![ItemNumber]).Caption = "'" & rst![ItemText] & "'"
  12.   End If
  13. End If
  14.  

Mary
Feb 5 '07 #2
Try this ...

Expand|Select|Wrap|Line Numbers
  1. If bolMenuVisible Then
  2.   Me("Option" & rst![ItemNumber]).Visible = True
  3.   Me("Option" & rst![ItemNumber]).Picture = "'" & rst![Icon] & "'"
  4.   Me("OptionLabel" & rst![ItemNumber]).Visible = True
  5.   Me("OptionLabel" & rst![ItemNumber]).Caption = "'" & rst![ItemText] & "'"
  6. Else
  7.   If (rst![ItemNumber] < 7) Or (rst![ItemNumber] > 9) Then
  8.     Me("Option" & rst![ItemNumber]).Picture = "'" & rst![Icon] & "'"
  9.     Me("Option" & rst![ItemNumber]).Visible = True
  10.     Me("OptionLabel" & rst![ItemNumber]).Visible = True
  11.     Me("OptionLabel" & rst![ItemNumber]).Caption = "'" & rst![ItemText] & "'"
  12.   End If
  13. End If
  14.  

Mary
Hi Mary
Thanks for that. However, it doesnt seem to do want I want. Im trying to lookup an embedded OLE value from tblImage, and place it in a command button.

Me("Option" & rst![ItemNumber]).PictureData = DLookup("IImage", "tblImage")

When this is executed, it returns an error about incorrect picture format.

Thanks
Feb 5 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Hi Mary
Thanks for that. However, it doesnt seem to do want I want. Im trying to lookup an embedded OLE value from tblImage, and place it in a command button.

Me("Option" & rst![ItemNumber]).PictureData = DLookup("IImage", "tblImage")

When this is executed, it returns an error about incorrect picture format.

Thanks
How are you identifying which image record to return. There is normally a third criteria statement on the DLookup function?

Can you give me an example of the embedded image file (i.e.) the value stored in the record.

Mary
Feb 5 '07 #4
How are you identifying which image record to return. There is normally a third criteria statement on the DLookup function?

Can you give me an example of the embedded image file (i.e.) the value stored in the record.

Mary
Even with the criteria set I still receive the same error (ie:)


Me("Option" & rst![ItemNumber]).PictureData = DLookup("IImage", "tblImage", "[IID] = 1")

The value stored in tblIImage is a .bmp file that I embedded in the table. The data type is OLE object, and I embedded simply by clicking insert new object.
Feb 5 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Even with the criteria set I still receive the same error (ie:)


Me("Option" & rst![ItemNumber]).PictureData = DLookup("IImage", "tblImage", "[IID] = 1")

The value stored in tblIImage is a .bmp file that I embedded in the table. The data type is OLE object, and I embedded simply by clicking insert new object.
Picture data is still looking for a string value. Try ...

Expand|Select|Wrap|Line Numbers
  1.  Me("Option" & rst![ItemNumber]).PictureData = "'" & DLookup("IImage", "tblImage", "[IID] = 1") & "'"
Failing this, open the bitmap in some image editing software and run save as to save the picture as a Windows Bitmap rather than any other type of bitmap just in case.

Change the OLE object from embedded to linked and see if that makes any difference.

The only other alternative (assuming the command button just can't reference an OLE object) is to create a bound OLE object on the form and change it to look like a command button. You should still be able to code a click event on it.

Mary
Feb 5 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish,...
2
by: Charles Robinson III | last post by:
How do I make Access display pictures within a form view as linked objects, so that the pictures which I am linking to are displayed within the database? I have a seperate folder for pictures to be...
3
by: Pedro Maria Ferro da Cunha | last post by:
I spend a lot of time making 2 thousand pictures and saving them as an article name. jpg. I have a table with the article name and name of the file in jpg (format). How can I make an...
0
by: Lyn | last post by:
I am having a frustrating time trying to do a simple insert of a BMP picture into a Bound Object Frame using both VBA and the Insert | Object... dialog. I had a separate post thread going on this...
21
by: MLH | last post by:
If I choose a command button on a form in design view, open the properties box and click the Picture property and its wiz button, I'm presented with a lengthy list of pictures. Everything from Add...
0
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is...
3
by: rcoco | last post by:
Hi, I want to share this problem. I have a datagrid that will help me Insert data into sql database. So I made a button On my form so that when I press the button a new row on datagrid should be...
7
by: kashif khan | last post by:
Hi All, I have created a form in MSAccess and linked that form with a table. now in the run mode if i am entering any thing in the textbox and closing the form with out clicking on add record...
10
by: Clamato | last post by:
Good Morning, I'm working with a form that basically add's a users windows logon ID, first name, and last name to a table. A list box on this form is then requeried once added displaying the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.