Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Northwind code issue for employee form.

Status
Not open for further replies.

Hayton

Technical User
Oct 17, 2001
257
NZ
Hello everyone,

I have copied this code from the Northwind database. the table is the Employees table and the form is the Employees form.

When I click on Add/Change command button in my application which is the same as the Northwind button, the begugger kicks in on the following line in the code sample pasted below:' With Application.FileDialog(msoFileDialogFilePicker)
'

Sub getFileName()
' Displays the Office File Open dialog to choose a file name
' for the current employee record. If the user selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

Could someone give some guidelines as to how to resolve this?



Hayton McGregor

 
Hayton,

You also need to copy the code in the "Modules" section of the Northwind database.[idea]


 
HitechUser,

Thanks for the reply. I have done that. It is showing the error as 'variable not defined' for the following:(msoFileDialogFilePicker)


Hayton McGregor

 
Hayton,

Open the original Northwind database and the press Alt + 11. this will open the VBA window. Select find and search for msoFileDialogFilePicker. Make sure you select all modules.

I would do this myself but my machine does not have the Northwind sample on it.

What version of Access?????




 
I am using Access 2003 on W2K

Hayton McGregor

 
Set a reference to Microsoft Office <version 11?> Object Library (in VBE - Tools | References)

Roy-Vidar
 
Roy-Vidar this reference has already been selected. I can't find the any other reference in the code to 'msoFileDialog...'

Hayton McGregor

 
You're sure you have a reference to the Microsoft Office object library?

The mso prefix on the constant (it's the constant used for the file dialog to display the file picker thingie), indicates it's located in the Microsoft Office library, not Access.

Anyway, just replace it with the number 3.

Roy-Vidar
 
Replace msoFileDialogFilePicker with the number 3, I mean.

Roy-Vidar
 
Roy-Vadar, you where correct I had made the wrong selection in my References.

That problem is now solved. I am trying to sort another out if I have no luck I will post another request.

Thanks for your help and advice.

Hayton McGregor

 
Hi Guys, when the subform loads, the debugger stops at the 'showImageFrame' line of code. The error is a Compile error which states - Sub or Function not defined.

Any suggestions greatly appreciated

Private Sub Form_Current()
' Display the picture for the current employee record if the image
' exists. If the file name no longer exists or the file name was blank
' for the current employee, set the errormsg label caption to the
' appropriate message.
Dim res As Boolean
Dim fName As String

path = CurrentProject.path
On Error Resume Next
errormsg.Visible = False
If Not IsNull(Me!Photo) Then
res = IsRelative(Me!Photo)
fName = Me![ImagePath]
If (res = True) Then
fName = path & "\" & fName
End If

Me![ImageFrame].Picture = fName
showImageFrame
Me.PaintPalette = Me![ImageFrame].ObjectPalette
If (Me![ImageFrame].Picture <> fName) Then
hideImageFrame
errormsg.Caption = "Picture not found"
errormsg.Visible = True
End If
Else
hideImageFrame
errormsg.Caption = "Click Add/Change to add picture"
errormsg.Visible = True
End If

End Sub

Hayton McGregor

 
Guys don't woryy about answering I think I have worked out what the problem is.


Hayton McGregor

 
Hayton,

I also have copied the same code from NWind from the employee form and I get the same error. Can you tell me how you worked around the error "msoFileDialogFilePicker"?
 
By setting the correct references, I guess, as explained above.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Penndro read Roy-Vidar comments above if you can't get your app to work them come back to us.

Roy-Vidars first response read as follows:'Set a reference to Microsoft Office <version 11?> Object Library (in VBE - Tools | References)'.

Hayton McGregor

 
Hi Hayton,

I followed Roy-Vidar's comments; however, I do not know how to go about making changes to the Microsoft Office object library. Were would I find this? Also, what value should I change/add?

Thanks,
Sandi
 
When in VBE (Alt-F11), menu Tools -> References ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi Penndro, I have been away from my PC for a few days. Have you managed to sort your problemout yet?

Hayton McGregor

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top