Accessing a Menu Item thru a Command button

M

Mota

Hi,
I want a code for a Command Button to open "Link Tables" Dialog box in ACC
2000.It would be equal to pointing to:
File menu>Get External Data>Import Tables...
Can anyone please help me?Thank you in advance.
 
R

Rick Brandt

Mota said:
Hi,
I want a code for a Command Button to open "Link Tables" Dialog box
in ACC 2000.It would be equal to pointing to:
File menu>Get External Data>Import Tables...
Can anyone please help me?Thank you in advance.

You're request is ambiguous. Do you want "Link" or "Import"? Here are both...

DoCmd.RunCommand acCmdLinkTables

DoCmd.RunCommand acCmdImport
 
R

Rick Brandt

Mota said:
Hi,
I want a code for a Command Button to open "Link Tables" Dialog box
in ACC 2000.It would be equal to pointing to:
File menu>Get External Data>Import Tables...
Can anyone please help me?Thank you in advance.

Your request is ambiguous. Do you want "Link" or "Import"? Here are both...

DoCmd.RunCommand acCmdLinkTables

DoCmd.RunCommand acCmdImport
 
A

Alex

Hi,

I have some code to do the job via vba if you want, rather than using
the wizard.

Regards

Alex
 
A

Alex

Hi Mota,

the code here is using the 'Microsoft ADO Ext. 2.8 for DDL and
Security' library (ADO)

how to to use

Call RelinkTable('MyTable','MyTable','c:\mymdb')

Function RelinkTable(strTable As String, strSourceTable As String,
strSourceDB As String) As Boolean
On Error GoTo Err_RelinkTable
Dim adocat As New ADOX.Catalog
Dim adotbl As New ADOX.TABLE
Set adocat = New ADOX.Catalog
Set adocat.ActiveConnection = CurrentProject.Connection
Set adotbl.ParentCatalog = adocat
On Error Resume Next
adocat.Tables.Delete strTable
On Error GoTo Err_RelinkTable
adotbl.NAME = strTable
adotbl.Properties("Jet OLEDB:Link Datasource") = strSourceDB
adotbl.Properties("Jet OLEDB:Link Provider String") = "MS Access"
adotbl.Properties("Jet OLEDB:Remote Table Name") = strTable
adotbl.Properties("Jet OLEDB:Create Link") = True
adocat.Tables.Append adotbl
Exit_RelinkTable:
Exit Function
Err_RelinkTable:
If Err.Number = -2147217860 Then
Exit Function
Else
Resume Next
End If
End Function


Hope it helps, if you want I will try and find the DAO version of the
code for you.

Regards


Alex
 
Top