Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Insert a picture into an OLE Unbound object using VB code

Posted on 2003-03-11
3
Medium Priority
?
346 Views
Last Modified: 2008-03-17
Hi

First of all i should make it clear that i am a complete newbie to VB. So flame me if you will, i am prepared :)

Here's my problem. Im using access 97 and have to design a database for school. I've decided to build an Address Book db and I want to be able to add pictures to the database. however, I want the user to be able to click a button to open a dialog window so they can select the picture file they would like to use. Is this possible? And if so where should i begin.

P.S
I looked on the internet for some tutorials that might cover this sort of stuff but didnt have much luck. Does anyone know any good links?

0
Comment
Question by:MuckyRabbit
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
yossigordin earned 60 total points
ID: 8110244
Hi MuckyRabbit,
Yes it is Possible, i have done the same thing.
you can compile a Dll in vb5 or vb6 to open dialogboxes for it.
Here's how it goes:
A)first make a Dll in vb
  1)make a class module and write
   Public Function ShowMyForm() As String

     Form1.Show 1
   
     ShowMyForm = s
   
     Unload Form1
   
   End Function
  2)create a form with a DriveListBox,DirlistBox,  FilelistBox and a command .
in the form code write:
  Private Sub Command1_Click()
     s = File1.Path & "\" & File1.FileName
     Unload Me
  End Sub
  Private Sub Dir1_Change()
      File1.Path = Dir1.Path
  End Sub
 
  Private Sub Drive1_Change()
      Dir1.Path = Drive1.Drive
  End Sub
  In the fileListBox in it's Pattern Property write:
*.bmp;*.jpg;*.gif
Than compile the Dll

B) use this Dll in your Access project the following way:
  1)in the code section on the tools/references add this Dll.
  2)in the eventProcedure of your buttonClick write:
   Dim c As New Project1.Class1
   Dim s As String
   s = c.ShowMyForm()
Now in s you will have the Exact Path of the selected file.
C)make an Image object and in it's source write:
  Image1.Source=s
That's it
Hope it helps,
yossigordin
 


 

0
 
LVL 1

Expert Comment

by:yossigordin
ID: 8110249
Hi MuckyRabbit,
Yes it is Possible, i have done the same thing.
you can compile a Dll in vb5 or vb6 to open dialogboxes for it.
Here's how it goes:
A)first make a Dll in vb
  1)make a class module and write
   Public Function ShowMyForm() As String

     Form1.Show 1
   
     ShowMyForm = s
   
     Unload Form1
   
   End Function
  2)create a form with a DriveListBox,DirlistBox,  FilelistBox and a command .
in the form code write:
  Private Sub Command1_Click()
     s = File1.Path & "\" & File1.FileName
     Unload Me
  End Sub
  Private Sub Dir1_Change()
      File1.Path = Dir1.Path
  End Sub
 
  Private Sub Drive1_Change()
      Dir1.Path = Drive1.Drive
  End Sub
  In the fileListBox in it's Pattern Property write:
*.bmp;*.jpg;*.gif
Than compile the Dll

B) use this Dll in your Access project the following way:
  1)in the code section on the tools/references add this Dll.
  2)in the eventProcedure of your buttonClick write:
   Dim c As New Project1.Class1
   Dim s As String
   s = c.ShowMyForm()
Now in s you will have the Exact Path of the selected file.
C)make an Image object and in it's source write:
  Image1.Source=s
That's it
Hope it helps,
yossigordin
 


 

0
 

Author Comment

by:MuckyRabbit
ID: 8118492
Thanks yossigodin, thats sounds good. All i need now is to get my hands on a copy of vb :) doubtful that the school will have one.

Thanks a million
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question