TRIBUN855 menghadirkan informasi lengkap seputar permainan online terbaru, akses VIP player, game online gratis, permainan tanpa uang asli serta berbagai fitur dan mekanisme permainan digital.
"Marty" <mbaril68@hotma il.com> wrote in message
news:1141338346 .573785.173750@ e56g2000cwe.goo glegroups.com.. .[color=blue]
> Access does not let me change the connection string. When I change it,
> it changes back when I exit the property value.[/color]
Hi Marty
This is a pretty standard question and there must be many examples posted.
You do realize that you cannot change this connection string by going in to
the design view of the linked table, don't you? (Access warns you of this)
Most of the posts to this group assume that you understand vba coding and
your question doesn't make it clear whether you are OK with this or not.
Here is an example where code is used to set up a couple of linke tables by
mapping the SQL table 'dbo.Product' to the linked Access table 'tblProducts'
and 'dbo.Order' to 'tblOrders'.
If this all seems incomprehensibl e, let us know.
Code follows:
Public Function ReLinkTables() As Boolean
On Error GoTo Err_Handler
Dim strConnect As String
Dim strTableList As String
Private Function LinkTables(strT ableList As String, strConnect As String) As
Boolean
On Error GoTo Err_Handler
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim astrTables() As String
Dim strTwoTables As String
Dim strSqlServerTab le As String
Dim strLinkTable As String
Dim lngPosition As Long
Dim lngCount As Long
Set dbs = CurrentDb
astrTables = Split(strTableL ist, ";")
For lngCount = 0 To UBound(astrTabl es())
strTwoTables = astrTables(lngC ount)
lngPosition = InStr(strTwoTab les, "|")
If (lngPosition > 0) And (Len(strTwoTabl es) > lngPosition) Then
strSqlServerTab le = Mid$(strTwoTabl es, 1, lngPosition - 1)
Private Function DeleteLinks(str TableList As String) As Boolean
On Error GoTo Err_Handler
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim astrTables() As String
Dim strTwoTables As String
Dim strLinkTable As String
Dim lngPosition As Long
Dim lngCount As Long
Dim blnError As Boolean
Set dbs = CurrentDb
astrTables = Split(strTableL ist, ";")
For lngCount = 0 To UBound(astrTabl es())
strTwoTables = astrTables(lngC ount)
lngPosition = InStr(strTwoTab les, "|")
If (lngPosition > 0) And (Len(strTwoTabl es) > lngPosition) Then
If Len(tdf.Connect ) > 0 Then
dbs.TableDefs.D elete tdf.Name
Else
' This is not a linked table
MsgBox "Cannot delete table '" & strLinkTable & "'",
vbExclamation
blnError = True
End If
Set tdf = Nothing
End If
End If
Next lngCount
If Not blnError Then
DeleteLinks = True
End If
Exit_Handler:
On Error Resume Next
dbs.TableDefs.R efresh
If Not dbs Is Nothing Then
Set dbs = Nothing
End If
"Marty" <mbaril68@hotma il.com> wrote in message
news:1141343359 .764166.122250@ z34g2000cwc.goo glegroups.com.. .[color=blue]
> Thanks. That worked perfectly. Is there a property to identify system
> tables other then the prefix "MSys"?[/color]
Not sure how it is connected to the original question, but there is a
constant in the DAO object library:
DAO.TableDefAtt ributeEnum.dbSy stemObject
so you could write
?IIF((((Current db.TableDefs(st rMyTable).Attri butes) AND
dbSystemObject) =0),"No","Yes")
to check this, but the only reason I could think for not trusting the "MSys"
prefix is that you suspect your users might be naming tables in a weird way
to spite you. And if this is the case, they may be able to set the
attributes to fake a system table.
Comment