Hi, Below is the code to export to the BE. There are 32 tbls! How do I program using vbs to bypass or enter the password automatically?
tbl_CA1InputNFileJanMar = "CA8InputFile_January_March_2013"
tbl_CA1InputNFileAprJun = "CA8InputFile_April_June_2013"
tbl_CA1InputNFileJulSep = "CA8InputFile_July_September_2013"
tbl_CA1InputNFileOctDec = "CA8InputFile_October_December_2013"
DoCmd.TransferDatabase transfertype:=acExport, _
databasetype:="Microsoft Access", _
databasename:="Z:\Turnaround Integrated Controls\1.4.12_Cost Control\Cost Performance Report\2013 Cost Performance Report\Performance Database\Data Database\TA2013_PR_TrackingDB.accdb", _
ObjectType:=acTable, Source:="" & tbl_CA1InputNFileJanMar & "", _
Destination:="" & tbl_CA1InputNFileJanMar & "", structureonly:=True
Here I found the Compact and Repair script using the feature I want, but do n ot know how to incorporate it:
Sub OpenPasswordProtectedDB()
'Define as Static so the instance of Access
'doesn't close when the procedure ends.
Static acc As Access.Application
Dim db As DAO.Database
Dim strDbName As String
strDbName = "C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb"
Set acc = New Access.Application
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=nwind")
acc.OpenCurrentDatabase strDbName
db.Close
Set db = Nothing
End Sub
Here is another example I found:
- Public Function fODBCTablesRefresh() As Boolean
- ' This function refreshes the DAO ODBC table connections
- ' listed in the qryODBCRefreshList query
- ' which in turn lists the first table to be connected for each different
- ' connection string listed in table tblDatabasesConnected.
- '
- ' This function is used to automate the initial refresh of the ODBC table connection
- ' so that updates etc can run without user intervention to supply the UID and PWD components
- ' of the DB connection.
- '
- ' 23/4/09
- '
- On Error GoTo refresh_err
- Dim daoDB As DAO.Database
- Dim tdef As DAO.TableDef
- Dim RS As DAO.Recordset
- Dim strConnectOld As String
- Set daoDB = CurrentDb
- Set RS = CurrentDb.OpenRecordset("qryODBCRefreshList")
- Do While Not RS.EOF
- Set tdef = daoDB.TableDefs(RS![tablename])
- strConnectOld = RS![Connect String]
- tdef.Connect = strConnectOld & "; UID=" & RS![USER ID] & "; PWD=" & RS![CONNECTION PASSWORD]
- tdef.RefreshLink
- tdef.Connect = strConnectOld 'restore no-password version of connect string
- RS.MoveNext
- Loop
- RS.Close
- fODBCTablesRefresh = True
- Exit Function
- refresh_err:
- fODBCTablesRefresh = False
- End Function