?
Solved

Insert a picture into an OLE Unbound object using VB code

Posted on 2003-03-11
3
Medium Priority
?
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

765 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