473,791 Members | 2,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting Pictures into Command Button from a Table

3 New Member
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 3985
MMcCarthy
14,534 Recognized Expert Moderator MVP
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
howser99
3 New Member
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 Recognized Expert Moderator MVP
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
howser99
3 New Member
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 Recognized Expert Moderator MVP
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
2426
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, Swedish or English). There are about a dozen tables with columns that need localization. Doing this in the application level was a no-goer. It would have taken far too much time (there is a *lot* of code and unfortunately most of the...
2
17731
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 placed in, and I have two pictures per record.
3
2678
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 instant attach to the database instead of adding picture
0
2346
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 and closed it off when I thought I had resolved the problem, but now I am back at square one. So I thought I would start afresh with a new post. Here is the problem... A few months ago, I set up a Bound Object Frame on a form which was tied to...
21
13018
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 Table, Address Book, Airplane to Underline, Undo, Undo (Rewind). I would like to know where they are stored. I thought it might be c:\program files\microsoft office\office\bitmaps but I don't think so. Anybody know where they are stored and...
0
3008
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 not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. Where Peter is the value entered in the textbox for firstname (fnameTBox) I'm sure the problem is something obvious but I...
3
4276
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 created and I could be able to insert data. But with this code below I've failed could someone help me and tell me where I'm going wrong: private void Page_Load(object sender, System.EventArgs e) { if (! IsPostBack)
7
3791
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 button then also the record is getting added in the table which I don't want to happen. What I want is only on click of command button the record should go in the table. If there is a new record in the textbox and I have closed the form without...
10
1834
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 names in this table. I'm ultimately trying to make it so the user can't add their information twice in this table. Well, you would think just making their ID the PK in the table would work, however I'm running into an issue with this. The user...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10427
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5431
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.