Common Dialog Control

G

Guest

I need help using this. My current code is:
Dim str As String
CommonDialog3.ShowOpen
imgquest.Picture = CommonDialog3.FileName
str = CommonDialog3.FileName
Question_Image.Value = str
However on my home PC it says 'Object doesn't support this property or
method'. Several people have pointed me to the article about using the API.
This does not currently work for what I'm trying to achieve AND increases my
file size from 2mb to 22mb (maybe due to image prob)!

I want to know either
1) How to use the API to get the selected path name of an image (from an
Open File dialog), store it in Question_Image then every time a record is
viewed get the pathname and use it to display the image in imgquest.
2) How to get the common dialog control reference.
 
D

Douglas J. Steele

Take a look at http://www.mvps.org/access/api/api0001.htm for a
comprehensive example of how to use APIs to get the standard Windows File
Open dialog. In my opinion, it's far superior to the the common dialog, so I
would strongly advise forgetting about using the dialog.

If you wanted to search for JPGs, for example, you could create a function
along the lines of:

Function GetJPG() As String
Dim strFilter As String

strFilter = ahtAddFilterItem(strFilter, "JPG Files (*.JPG)", "*.JPG")
GetJPG = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select a picture...", _
Flags:=ahtOFN_HIDEREADONLY)

End Function

You'd use that function like:

Dim str As String
str = GetJPG()
imgquest.Picture = str
Question_Image.Value = str
 
G

Guest

Ok that works very well when getting the image for the first time, but how
can I make it get the pathname every time the record is accessed? I
currently have (on record next and previous):

DoCmd.GoToRecord , , acPrevious
If imgquest.Picture <> Null Then
imgquest.Picture = Question_Image.Value 'trying to make the image
equal to the pathname, so gets image
Else
imgquest.Picture = "C:\Documents and Settings\Images\blank.bmp"
'image that should be displayed if non selected.
End If
 
G

Guest

Sorry, instead of
If imgquest.Picture <> Null Then

it should be
If Question_Image.Value <> Null Then
 
D

Douglas J. Steele

You can't check for Null that way.

Try:

If IsNull(Question_Image.Value) = False Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top