Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 8th, 2011, 06:52 AM
Registered User
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Link Table to a Directory Path that need to be changed every month?

Dear all, I am new to the forum.

had tried to find all solution on the internet, I come out with below and clearly it is not working as intended.

All I want is to set up a VBA input table. so when I click on it. I will ask me to key in Month. Let say Dec2011,

So the Database will link to a table of pathname with Dec2011 in the target dababase.

Sub Linkt()

Set db_hhz = CurrentDb
Dim Month As String
Dim Year As Double
Dim Mon As Double
Dim Initial As Double

Month = Me.Mmm_box
Year = Me.YYYY_box
Mon = Me.MM_box

Dim dbsTemp As Database
Dim strMenu As String
Dim strInput As String

' Open a Microsoft Jet database to which you will link
' a table.
Set dbsTemp = CurrentDb

' Call the ConnectOutput procedure. The third argument
' will be used as the Connect string, and the fourth
' argument will be used as the SourceTableName.
ConnectOutput dbsTemp, _
";DATABASE=G:\PROJECTS\Mis\Inwards\Garwyn Input Files\" & Month & Year & """\EQUITAS DATA.mdb", _
End Sub

Sub ConnectOutput(dbsTemp As Database, _
strTable As String, strConnect As String, _
strSourceTable As String)

Dim tdfLinked As TableDef

' Create a new TableDef, set its Connect and
' SourceTableName properties based on the passed
' arguments, and append it to the TableDefs collection.
Set tdfLinked = dbsTemp.CreateTableDef(strTable)

tdfLinked.Connect = strConnect
tdfLinked.SourceTableName = strSourceTable
dbsTemp.TableDefs.Append tdfLinked

End Sub


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting the path directory yukijocelyn ASP.NET 2.0 Basics 1 October 8th, 2007 10:22 PM
query Current Month, Month+1, Month+2, Month+3 anterior Access 2 September 24th, 2006 08:25 PM
Finding user's home directory path bluckcuck Excel VBA 3 July 18th, 2005 09:23 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.