Open the file open api via command button

G

Guest

I have been looking at the vba code at the following site
http://www.mvps.org/access/api/api0001.htm, which seems standard for
open/save dialog boxes. The trouble is ive tried using the code and cant get
it to work. I just dont under the code (due to lack of experience). if
someones got some time can they talk me through the code please

Many Thanks
 
D

Douglas J. Steele

The samples at the top show how to use it: you specify one or more file
filters (*.txt, *.mdb, *.xls, that sort of thing) by calling
ahtAddFilterItem, then you call ahtCommonFileOpenSave. If you select a file,
it'll be passed back by the function. If you don't select a file, nothing's
passed back.

What problem are you having? Are you getting an error message? If so, what
is it?

A common mistake is to name the module the same as a routine within the
module.
 
G

Guest

Thanks for info, it is now working. I'll try my best to go throught the code
and understand it, in the mean time i want the open file menu to open only
picture files, bmp, gif, jpeg. How would i write this in the code. Also when
selecting a file and pressing open, what part of the code decides where the
selected file is going to go?? im want to open a picture and store it in a
table with only one recordset (Row)
 
D

Douglas J. Steele

Nothing in the code "decides where the selected file is going to go". All
the code does is return a file name to you: you have to write your own code
to do something with that file.

To limit the selection to bmp, gif, jpeg (and, I presume, jpg), use:

strFilter = ahtAddFilterItem(strFilter, "Pictures",
"*.bmp;*.gif;*.jpg;*.jpeg")
 
G

Guest

Many Thanks Gents

Douglas J. Steele said:
Nothing in the code "decides where the selected file is going to go". All
the code does is return a file name to you: you have to write your own code
to do something with that file.

To limit the selection to bmp, gif, jpeg (and, I presume, jpg), use:

strFilter = ahtAddFilterItem(strFilter, "Pictures",
"*.bmp;*.gif;*.jpg;*.jpeg")
 
G

Guest

The selected file from the open dialog now goes into a table of mine as long
binary data. Im now trying to view the file on a form, using a bound picture
where its control sourse is the field in the table. When i click on the
picture frame (no picture visuble in it) it comes up with an error msg A
problem occurred while database was communicating with the OLE server or
activeX control. Close OLE server and restart it outside of database. Then
try the original operation again in Database.

Am i going down the right track here???
 
D

Douglas J Steele

You'll have to provide more details, like what version of Access are you
using, what operating system and what's the actual code you're using to put
the data into the table.
 
G

Guest

Thanks for the response, im using Access2003 with windows XP. the code in
using in the on click event of my cmd button is :

Private Sub cmdOpenApiForLogo_Click()
Dim strStartDir As String

Dim strFilter As String
Dim lngFlags As Long

strStartDir = CurrentDb.Name
strStartDir = Left(strStartDir, Len(strStartDir) - Len(Dir(strStartDir)))


' strFilter = ahtAddFilterItem(strFilter,
"Pictures","*.bmp;*.gif;*.jpg;*.jpeg")

strFilter = ahtAddFilterItem(strFilter, "Pictures",
"*.bmp;*.gif;*.jpg;*.jpeg")


Me.Text0 = ahtCommonFileOpenSave(InitialDir:="c:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Select database")
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
End Sub

Where Text0 is a text box, the text box's control sourse is "CompanyLogo" a
field in a table named "tblOurCompanyInfo".

The bound picture frames control source is also "CompanyLogo"

Hope this info is what you need

Regards

StuJol
 
G

Guest

Ive been able to sort this problem out by using the code from the northwind
sample database from the Employees form

Many thanks for time spent investigating for me
 

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

Top