Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA to open a .mdb file


Hello programmers!

I want to use vba code to open a Microsoft Access File.

Below is the path. I tried to record the action, but it didn't work.

I:\Documents\SHIFTLOG\Shiftlog with Prod.mdb

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=495854

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA to open a .mdb file

Hi EMoe,

Congratulations! You are about to enter the wonderful world of DAO or Data
Access Objects. DAO is how microsoft exposes Access objects to VBA. The
steps are such:

1. Make sure DAO is referenced within your VBA project. Go to Tools -
References - and select Microsoft DAO 3.x Object Library
2. Once this is open you will be able to insert the objects and methods that
allow you to control Access within VBA.
3. The programming from this point is actually quite elaborate and requires
some experience and knowledge of databases. I suggest consulting the online
help as it is actually very good.

With that said, here are the very simple steps that will at least "Open" the
mdb:

Dim wrkJet As Workspace
Dim dbsNorthwind As Database

Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)

' Open Database object from saved Microsoft Jet database for exclusive use.
Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb", _
True)

Good luck!

M C Del Papa

"EMoe" wrote in message
...

Hello programmers!

I want to use vba code to open a Microsoft Access File.

Below is the path. I tried to record the action, but it didn't work.

I:\Documents\SHIFTLOG\Shiftlog with Prod.mdb

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile:
http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=495854



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default VBA to open a .mdb file


did. DAO is obsolete and new users should use ADO.

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


M C Del Papa wrote :

Congratulations! You are about to enter the wonderful world of DAO or
Data Access Objects. DAO is how microsoft exposes Access objects to
VBA. The steps are such:

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default VBA to open a .mdb file

Have you looked at using "Shell" ?

Tim

--
Tim Williams
Palo Alto, CA


"EMoe" wrote in message
...

Hello programmers!

I want to use vba code to open a Microsoft Access File.

Below is the path. I tried to record the action, but it didn't work.

I:\Documents\SHIFTLOG\Shiftlog with Prod.mdb

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile:

http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=495854



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA to open a .mdb file

Do you want to access the data in the mdb file, or just start the database
within an Access instance?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"EMoe" wrote in message
...

Hello programmers!

I want to use vba code to open a Microsoft Access File.

Below is the path. I tried to record the action, but it didn't work.

I:\Documents\SHIFTLOG\Shiftlog with Prod.mdb

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile:

http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=495854





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA to open a .mdb file


I don't want to open the database, but the actual file by its name. This
one is still stumping me???

Bob Phillips Wrote:
Do you want to access the data in the mdb file, or just start the
database
within an Access instance?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"EMoe" wrote in
message
...

Hello programmers!

I want to use vba code to open a Microsoft Access File.

Below is the path. I tried to record the action, but it didn't work.

I:\Documents\SHIFTLOG\Shiftlog with Prod.mdb

Thanks,
EMoe


--
EMoe

------------------------------------------------------------------------
EMoe's Profile:

http://www.excelforum.com/member.php...o&userid=23183
View this thread:

http://www.excelforum.com/showthread...hreadid=495854



--
EMoe
------------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=495854

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default VBA to open a .mdb file

Look at "Shell"

Tim

--
Tim Williams
Palo Alto, CA


"EMoe" wrote in message
...

I don't want to open the database, but the actual file by its name. This
one is still stumping me???

Bob Phillips Wrote:
Do you want to access the data in the mdb file, or just start the
database
within an Access instance?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"EMoe" wrote in
message
...

Hello programmers!

I want to use vba code to open a Microsoft Access File.

Below is the path. I tried to record the action, but it didn't work.

I:\Documents\SHIFTLOG\Shiftlog with Prod.mdb

Thanks,
EMoe


--
EMoe

------------------------------------------------------------------------
EMoe's Profile:

http://www.excelforum.com/member.php...o&userid=23183
View this thread:

http://www.excelforum.com/showthread...hreadid=495854



--
EMoe
------------------------------------------------------------------------
EMoe's Profile:

http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=495854



  #8   Report Post  
Posted to microsoft.public.excel.programming
TK TK is offline
external usenet poster
 
Posts: 177
Default VBA to open a .mdb file

EMoe:

As keepiTcool points out, ADO is the newest
(really not that new) and the recomended way
to go by people that recomend things like that.

Here is a procedure that willl get you statrd in that direction.

Good Luck
TK

Private Sub CommandButton4_Click()

On Error GoTo ErrHandler

Dim rg As Range
Set rg = ThisWorkbook.Worksheets(2).Range("a1")

'To use ADO objects in an application add a reference
'to the ADO component. From the VBA window select
'Tools/References< check the box
' "Microsoft ActiveX Data Objects 2.x Library"

'You must fully quality the path to YOUR file

Dim db_Name As String
db_Name = ("C:\Program Files\Microsoft Visual Studio\VB98\NWind.mdb")
Dim DB_CONNECT_STRING As String

DB_CONNECT_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"data Source=" & db_Name & ";" & ", , , adConnectAsync;"

'Create the connection
Dim cnn As New ADODB.Connection
Set cnn = New Connection
cnn.Open DB_CONNECT_STRING

'Create the recordset
Dim rs As ADODB.Recordset
Set rs = New Recordset

'Determines what records to show
Dim strSQL As String
strSQL = "SELECT CompanyName, ContactName, City, Country " & _
"FROM Customers ORDER BY CompanyName"

'Retreive the records
rs.CursorLocation = adUseClient
rs.Open strSQL, cnn, adOpenStatic, adLockBatchOptimistic

'Test to see if we are connected and have records
Dim num As Integer
num = rs.RecordCount

Dim num1 As Integer
num1 = rs.Fields.Count

If cnn.State = adStateOpen Then
MsgBox "Welcome to! " & db_Name & " Records = " & num & " Fields =
" & num1, vbInformation, _
"Good Luck TK"
Else
MsgBox "Sorry. No Data today."
End If

'Copy recordset to the range
rs.MoveLast
rs.MoveFirst
rg.CopyFromRecordset rs
rg.CurrentRegion.Columns.AutoFit

'close connection
cnn.Close
Set cnn = Nothing
Set rs = Nothing

Exit Sub

ErrHandler:
MsgBox "Sorry, an error occured. " & Err.Description, vbOKOnly
End Sub

"EMoe" wrote:


Hello programmers!

I want to use vba code to open a Microsoft Access File.

Below is the path. I tried to record the action, but it didn't work.

I:\Documents\SHIFTLOG\Shiftlog with Prod.mdb

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=495854


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA to open a .mdb file


Thanks for all the input.

I just want to open an Access File. The file when opened has severa
buttons that goes to a *front page form*, where I can click an icon t
proceed further to a page in Access.

I have absolutely no experience with Access. I thought that th
programming for excel, to open such a file, would be a simple code ad
in. Looking at some of the suggestions here, I guess it's a little mor
differcult; but I'm willing to try.

Thanks Again,
EMo

--
EMo
-----------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...fo&userid=2318
View this thread: http://www.excelforum.com/showthread.php?threadid=49585

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default VBA to open a .mdb file

then

Shell "c:\path\mydb.mdb"

should do the trick

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


EMoe wrote :


Thanks for all the input.

I just want to open an Access File. The file when opened has several
buttons that goes to a *front page form*, where I can click an icon to
proceed further to a page in Access.

I have absolutely no experience with Access. I thought that the
programming for excel, to open such a file, would be a simple code add
in. Looking at some of the suggestions here, I guess it's a little
more differcult; but I'm willing to try.

Thanks Again,
EMoe



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA to open a .mdb file


Hi Keep it cool!

Here is what I set up, but it didn't work.

Sub OpenLog ()
Shell "I:\Plant\SHIFTLOG\Shiftlog with Prod.mdb"
End Sub

Is this right?

EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=495854

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default VBA to open a .mdb file

Hi Emoe,

my mistake, try:

Sub OpenLog()
cPATH = "I:\Plant\SHIFTLOG\Shiftlog with Prod.mdb"
Shell "msaccess.exe """ & cPath & """", vbMaximizedFocus
End Sub


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


EMoe wrote :


Hi Keep it cool!

Here is what I set up, but it didn't work.

Sub OpenLog ()
Shell "I:\Plant\SHIFTLOG\Shiftlog with Prod.mdb"
End Sub

Is this right?

EMoe

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. Phillip Pi Excel Discussion (Misc queries) 0 April 23rd 09 08:53 PM
In Excel - Use Windows Explorer instead of File Open to open file KymY Excel Discussion (Misc queries) 1 August 5th 06 09:59 PM
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 2 July 8th 05 05:51 AM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 0 July 2nd 05 08:41 PM


All times are GMT +1. The time now is 12:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"