4.00
WINDOWS
kbusage
The information in this article applies to:
- Standard, Professional, and Enterprise Editions of Microsoft Visual
Basic, 32-bit only, for Windows, version 4.0
SYMPTOMS
DataForms Designer under Windows 95 does not recognize a Microsoft Access
7.0 database and generates the error: "Can't open DataBase "c:\xxx.mdb" It
may not be a Database or the file may be corrupt".
Steps to Reproduce the Problem
- Start Visual Basic or from the File menu, choose New Project (ALT, F,
N).
- From the Add-ins menu select Data Form Designer. If Data Form Designer
is not available choose Add-in-manager and add it to the menu.
- After selecting Data Form Designer click on the Opendatabase button on
Data form designer dialog and select the Northwind.mdb from the samples
directory of the Access application. The error message will display at
this point.
CAUSE
In the dfd.frm which is in the data wizard sample, there is a subroutine
Sub cmdOpenDB_Click which includes a case statement that incorrectly has a
dlgDBOpen.Flags setting of &H4 or the constant value for
cdlOFNHideReadOnly. The dlgDBOpen.Flags needs to be assigned the
cdlOFNExplorer constant value which can be located in the object browser.
RESOLUTION
- Start VB4-32 and load the dfd.vbp project from the samples\datawiz
directory of VB4-32.
- View the code of dfd.frm file and locate the cmdOpenDB_Click procedure.
- Change the value assigned to the dlgDBOpen.Flags setting which is shown
below with the incorrect setting.
With dlgDBOpen
.FilterIndex = 1
.FileName = msDBName '""
.CancelError = True
.Flags = &H4
.Action = 1
End With
To change the constant value for dlgDBOpen.Flags:
- Highlight the &H4 value.
- Press the F2 key to bring up the Object Browser.
- From the Libraries/Projects drop down list box Select "MSComDlg -
Microsoft Common Dialog Control."
- Under Classes/Modules, select FileOpenConstants.
- Under Methods/Properties, select cdlOFNExplorer, then click the Paste
button.
- From the VB file menu, choose Make Ole Dll File, and save to the
samples\datawiz directory of VB4-32.
- In a new project, detach then reattach the DataForm Designer to the Add-
ins menu. It will now recognize a Microsoft Access 7.0 database.
|