Full Version: Windows Dialog Box error: user defined type not defined
UtterAccess Forums > Microsoft® Access > Access Forms
Kai
Hi. I have been using OpenFileDialog to well open a windows dialog box. Recently my company upgraded from MS Access 2002 to 2003 and now when I run my database in the new version I get a compile error: user defined type not defined. Is this just a compatibility problem between the 2 versions or do I need to open a windows dialog box in a new way?
Thank you.
Kai
adaytay
Hi,
o into your References dialog in the VBE Window (Tools > References), and check to see if any are "MISSING". If they are you need to scroll down the list until you find them. Put a tick back in the relevant box(es) and recompile, it should then run with no problems.
HTH,
Ad
Kai
I checked the references and none of them are missing. Do you know the specific reference for the dialog box?
Thank you.
Kai
adaytay
There isn't one... it's an API Call.
Try to compile the code. On what line of the code does the error occur?
Ad
Kai
The error occurs on the bold line bellow:
Dim idlg As New CommonDialogAPI
Dim lngFormName As Long
Dim lngAppInstance As Long
Dim strInitDir As String
Dim strFileFilter As String
Dim lngResult As Long

lngFormName = Me.Hwnd
MsgBox lngFormName, vbCritical
lngAppInstance = Application.hWndAccessApp
strInitDir = "C:\Documents and Settings\chumiston\My Documents"
strFileFilter = "Excel Spreadsheets (*.xls)" & Chr(0) & "*.xls; "
'opens dialog box
lngResult = idlg.OpenFileDialog(lngFormName, lngAppInstance, strInitDir, strFileFilter)
'Establishes selection of file
If idlg.GetStatus = True Then
Me.Filename1 = Trim(idlg.GetName)

Else
MsgBox "No file selected."

End If
Thank you for your help
Kai
adaytay
Hi,

Can you doublecheck that you have the CommonDialogAPI class module present in your project?

HTH,

Ad
Kai
That was the problem. I didn't have the CommonDialogAPI class module in my project. Thank you very much for your help.
ai
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.