Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

creare o eliminare link a tabella da vba se db esiste

198 views
Skip to first unread message

tmtube

unread,
Jan 10, 2014, 3:59:38 PM1/10/14
to
vorrei creare un collegamento ad una tabella se un certo db esiste,
eliminate tale collegamento se il db non esiste

per sapere se esiste o non esiste posso usare Dir (percorso) ma una volta
scoperto se esiste o meno come "creo o elimino" il collegamento ad una certa
tabella

grazie.

Karl Donaubauer

unread,
Jan 11, 2014, 9:57:06 AM1/11/14
to
p.e.

Dim strFullPath As String
Dim blnExists As Boolean

strFullPath = "C:\Percorso\Bello.accdb"
blnExists = DCount("*", "MSysObjects", "Name='TabellaCollegata'") > 0

If Dir(strFullPath) > "" Then
If blnExists Then DoCmd.DeleteObject acTable, "TabellaCollegata"
DoCmd.TransferDatabase acLink, "Microsoft Access", _
strFullPath, acTable, "TabellaOrigine", "TabellaCollegata"
Else
If blnExists Then DoCmd.DeleteObject acTable, "TabellaCollegata"
End If


La prova con blnExists nel IF evita doppioni, nel ELSE messaggi di errore.

--
Ciao
Karl
*********
Access FAQ: http://www.donkarl.com/it


tmtube

unread,
Jan 12, 2014, 11:17:36 AM1/12/14
to

>p.e.

>Dim strFullPath As String
>Dim blnExists As Boolean

>strFullPath = "C:\Percorso\Bello.accdb"
>blnExists = DCount("*", "MSysObjects", "Name='TabellaCollegata'") > 0

>If Dir(strFullPath) > "" Then
> If blnExists Then DoCmd.DeleteObject acTable, "TabellaCollegata"
> DoCmd.TransferDatabase acLink, "Microsoft Access", _
> strFullPath, acTable, "TabellaOrigine", "TabellaCollegata"
>Else
> If blnExists Then DoCmd.DeleteObject acTable, "TabellaCollegata"
>End If


>La prova con blnExists nel IF evita doppioni, nel ELSE messaggi di errore.

>--
>Ciao
>Karl
>*********
Access FAQ: http://www.donkarl.com/it

Ti far� un mezzo busto in qualche piazza :)

0 new messages