PDA

Click to See Complete Forum and Search --> : Opening Access DB with CommonDlg Control


Stanley
Aug 30th, 1999, 07:13 PM
I am trying to get an Access database to open using the Microsoft Common Dialog Control.


Private Sub MnuFileOpen_Click()
CommonDialog1.ShowOpen


Data1.Connect = Access
Data1.DatabaseName = CommonDialog1.FileName
Data1.Caption = CommonDialog1.FileTitle
Data1.RecordSource = "table"

End Sub

This code doesn't appear to work. When the database is opened, I would hope that it should populate the existing fields on the form. Any help would be appreciated.

JHausmann
Aug 30th, 1999, 09:12 PM
try adding :

data1.refresh


(after data1.recordsource)

Note:
Data1.RecordSource should be set to your table name (if it's Table, thats not wise) or query, if you're trying to set the Recordset type, use the following instead:

Data1.RecordsetType= 0 ' which is "table"

[This message has been edited by JHausmann (edited 08-31-1999).]

Castor
Aug 31st, 1999, 10:41 PM
I'm not sure if the code you typed is verbatim out of your app or not, but where you have
Data1.Connect = Access

Is Access a string variable that you've assigned a value to? I know that that property is expecting to see a string. If this is your problem, and you haven't declared the Option Explicit keyword, I would suggest you do that because it will catch errors like this.

Of course if that isn't verbatim and you do have it typed correctly in your code, you can ignore this whole message :)

Castor