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.
[code]
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, _
"CASE_EQU", _
";DATABASE=G:\PROJECTS\Mis\Inwards\Garwyn Input Files\" & Month & Year & """\EQUITAS DATA.mdb", _
"CASE_EQU"
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
/[code]
|