Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 24th, 2005, 03:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 126
Thanks: 5
Thanked 0 Times in 0 Posts
Default OLE Object based on If statement

I have two ole objects in a table specified as my "look up" table.
I want one ole object to show up for one value in a field, and a different one for a different value. I have the below code in there...but I know its wrong because...duh! it's not working! :D

In the look up table, the ole objects are in records 1 & 2 of the "logo" field. If the value is "Stant", I want the ole object in record #1 to show up. If the value is "STC", I want the ole object in record #2 to show up.

If Company = "Stant" Then CompanyLogo = [lookuptable]![Logo]!record = 1

Any help would be much appreciated!

Regards,
Laura

The only thing standing between you and your goal is doubt. Quit doubting yourself and you'll be able to accomplish anything!
__________________
Regards,
Laura

The only thing standing between you and your goal is doubt. Quit doubting yourself and you'll be able to accomplish anything!
 
Old October 25th, 2005, 08:49 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I haven't done this before. Your code should look more like:
I would place both logos on the form where you want them, and set both of them to Visible = No.

Dim stCompany As String
Me.StantLogo.Visible = False
Me.OtherLogo.Visible = False

If IsNull(Me.CompanyControlName) Then
   stCompany = " "
   Else
   stCompany = Me.CompanyControlName
End If

If stCompany = "Stant" Then
   Me.StantLogo.Visible = True
   Else
   Me.OtherLogo.Visible = True
End If

You may want to add other conditions to this set up. In any event, I would do it this way rather than call images from the records. I think you would have to set the record source of the control to do it your way. This way is manageable in smaller apps, but if you had dozens of forms and you changed the logo, then it would take a few minutes to make all the changes.

Anywho, HTH


mmcdonal
 
Old October 25th, 2005, 08:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 126
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Thank you for your reply, but I tried this type of thing already, but I need it to link the ole object to the actual record. If I use this method, it changes the background of the form and not the value of the field containing the logos.

Any other ideas?

Regards,
Laura

The only thing standing between you and your goal is doubt. Quit doubting yourself and you'll be able to accomplish anything!
 
Old October 25th, 2005, 02:40 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You misunderstand.
Save the logo image as a .jpg file.
Click on the form and then select Insert>Image>From File
Then browse to one logo and insert it on the form in the size and location you want it.
Then do the same thing for the second logo, and place it on top of the first logo.
Then set both of their Visible properties to No.
Then insert this code on the On Current event of the form, or on the After Update event of your control.
This will make the small logo appear and disappear depending on the text box value.
If you inserted the images and made them the size of the form, then it will be the background, but you can resize the image. Make sure you don't have Clip selected for the image so you can make it as small as you want. Clip will force you to make the image regular size.

If you want to get more elegant, you can create the logo at the size you want it to display on your form in PhotoShop so it is a better quality resampling than what Access will do. Access will degrade your image if you shrink it.

With this method you won't need to save your images to an image table, but you will have to do some hand work.

I know you can do this the way you are thinking, but I don't have time to look it up at the moment. Try searching Microsoft Access Development center for displaying images. I know there is a good article there, but it involves a lot of code. I have used their method before.

HTH

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
The OLE object is empty leegweaver Access VBA 4 June 20th, 2008 07:59 AM
embeding an OLE object ricespn Beginning VB 6 0 August 17th, 2007 12:47 AM
ole object insertion vinodkselpy Crystal Reports 0 March 1st, 2007 07:31 AM
OLE object in ASP MDrumm BOOK: Beginning ASP 3.0 3 June 18th, 2005 10:48 AM
OLE Object Type? j.gonsalves@ntlworld.com Access VBA 1 October 20th, 2004 02:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.