Compile error: Variable not defined

G

Guest

I already posted this before, but I don't see it anywhere so I'm posting again..

I developed a small database in Access XP but need to quickly get it running in Access 2K. I'm fairly new and I simply used XP's "convert" utility to change it to Access 2K format

The database keeps information on vehicles and one record field is the textual path to the location of an image file that displays in an image control on the database form and changes accordingly as you move through the records

The Access XP sample database for Northwind has an Employees form that does the same thing, so I simply lifted the code from there, and it works great. However, on the version I converted to 2K, I now get a compile error "variable not defined" on (msoFileDialogFilePicker) when I try to edit this field through the form

It should open up the "File Open" dialog to allow the user to select the path to the image file which is then stored in the text field and which controls the image that displays in the image control for each record

The code is listed below and I know the answer will be obvious to anyone with more experience than me, so I'd be grateful if you would tell me what I need to do to make this work, please. I guess it's something XP has that 2K doesn't

Thanks

Sub getFileName(
' Displays the Office File Open dialog to choose a file nam
' for the current vehicle record. If the user selects a fil
' display it in the image control
Dim fileName As Strin
Dim result As Intege
With Application.FileDialog(msoFileDialogFilePicker
.Title = "Select Picture
.Filters.Add "All Files", "*.*
.Filters.Add "JPEGs", "*.jpg
.Filters.Add "Bitmaps", "*.bmp
.FilterIndex =
.AllowMultiSelect = Fals
.InitialFileName = CurrentProject.pat
result = .Sho
If (result <> 0) The
fileName = Trim(.SelectedItems.Item(1)
Me![ImagePath].Visible = Tru
Me![ImagePath].SetFocu
Me![ImagePath].Text = fileNam
Me![Notes].SetFocu
Me![ImagePath].Visible = Fals
End I
End Wit
End Sub
 
M

Marshall Barton

Paul said:
I developed a small database in Access XP but need to quickly get it running in Access 2K. I'm fairly new and I simply used XP's "convert" utility to change it to Access 2K format.

The database keeps information on vehicles and one record field is the textual path to the location of an image file that displays in an image control on the database form and changes accordingly as you move through the records.

The Access XP sample database for Northwind has an Employees form that does the same thing, so I simply lifted the code from there, and it works great. However, on the version I converted to 2K, I now get a compile error "variable not defined" on (msoFileDialogFilePicker) when I try to edit this field through the form.

It should open up the "File Open" dialog to allow the user to select the path to the image file which is then stored in the text field and which controls the image that displays in the image control for each record.

The code is listed below and I know the answer will be obvious to anyone with more experience than me, so I'd be grateful if you would tell me what I need to do to make this work, please. I guess it's something XP has that 2K doesn't?


It think the answer is even more obvious than you know ;-)

The FileDialog object did not exist prior to Office XP.

If you're up to it, a "better" way to provide users with a
browse feature is:
http://www.mvps.org/access/api/api0001.htm
 
G

Guest

Marshall

Thanks for the reply, which I'll take a look at

A far more simple solution is that my customer upgrades to XP, in which case I have to do nothing more ;0

Cheers.
 

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