Open a Access Dbase File

dantb

Active Member
Joined
Mar 20, 2002
Messages
358
Hi all, what I am trying to do is open a dbase file. I have no problem opening a workbook, but how can I change my sub to open a Acces file (labor dbase.mbd)
I know the workbooks.open is wrong but dont know what to substitute, and can it also open one of the forms within the dbase file at the same time. Thx Dan

FrmLbedit.Hide
ChDir "C:Unit PriceDbase"
Workbooks.Open Filename:="C:Unit PriceDocumentsCharges.xls"
 
What !!?

My code opens an mdb AND the form..

..plus DAO is completely irrelevant for your request !

Still, I guess Tom knows you better...
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Well not really, Still working on the problem,Tstom &Sutjh. But maby getting closer!. I have made sure that this option was checked. (Micosoft Access 9.0 Object Library), Still getting erors,I might just have something in the wrong place, But trying. This is what I have so far.

Private Sub CmdMtr_Click()
Dim oApp As New Access.Application
Dim strDB As String
Dim stFormName As String
Sub OpenAccessDB()
strDB = "C:UnitPriceDbaseUnit Price.mbd"
stFormName = "CS Material"

With oApp
.OpenCurrentDatabase strDB
.DoCmd.OpenForm stFormName
.Visible = True
.UserControl = True
End With
End Sub
 
Upvote 0
hey,dan..
just in case, can you check that in your code your path ends in .mdb and not .mbd ? Also that you don't have "Sub OpenAccessDB()" stuck in there.

If that's not it, try this and let me know what error you get...

'*****************************
Private Sub CmdMtr_Click()
On Error GoTo Err_CmdMtr_Click

Dim oApp As New Access.Application
Dim strDB As String
Dim stFormName As String

strDB = "C:UnitPriceDbaseUnitPrice.mdb"
stFormName = "CS Material"

With oApp
.OpenCurrentDatabase strDB
.DoCmd.OpenForm stFormName
.Visible = True
.UserControl = True
End With


Exit_CmdMtr_Click
Set oApp = Nothing
Exit Sub

Err_CmdMtr_Click:
MsgBox "Error " & Err & ": " & Error(Err)
Resume Exit_CmdMtr_Click

End Sub
'*****************************

It's probably bet to set oApp to nothing if you are gettihg errors, otherwise you might have some invisible Access applications hanging around !
 
Upvote 0
Hi sutjh, tryed it both ways after fixing error. This is what I have and error recieved.
Private Sub CmdMtr_Click()
Dim oApp As New Access.Application
Dim strDB As String
Dim stFormName As String
strDB = "C:UnitPriceDbaseUnitPrice.mdb"
stFormName = "CS Material"

With oApp
.OpenCurrentDatabase strDB
.DoCmd.OpenForm stFormName
.Visible = True
.UserControl = True
End With
End Sub

The Private Sub line has a Yellow arrow by it, and(oApp As New Access.Application)is highlighted.
Error Mesage - compile error : User-defined type not defined.
 
Upvote 0
IT WORKS WEEEEEE>>>> Thank you so much Sutjh, The code wasnt the problem, I had Microsoft Office 9.0 Library checked in References , Neaded Microsoft Access Objects Library Checked. Thanks again for your Help, only been working with vba 3 months, Lots to learn, have a good one Dan
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,107
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top