est il possible de faire un drop table sur une BdD distante ?
Pour une fois je pose la question avant de dire bjr, pour éviter que la
monotonie s'installe.
Le beau temps arrive mais la chaleur pas encore (en Bretagne) m'en fous je
bosse.
Denis
' pour renommer une champ sur une table distante '----- Public Sub RenommerChampDAO(ByVal strBase As String, ByVal strTbl As String, ByVal NchOld As String, ByVal NchNew As String) On Error GoTo err: Dim db As DAO.Database Dim tabb As DAO.TableDef Dim chp As DAO.Field Set db = OpenDatabase(strBase) Set tabb = db.TableDefs(strTbl) Set chp = tabb.Fields(NchOld) chp.Name = NchNew Set chp = Nothing Set tabb = Nothing Set db = Nothing Exit Sub err: MsgBox "L'action renommer le champ a échouée" End Sub '---- 'lancement par Call RenommerChampDAO(n_BdD, n_tabl, n_ch_old, n_ch_new) '----- 'pour supprimer une table dans une BdD distante '----- Public Function DeleteTableExt(ByVal strDb As String, ByVal strTbl As String) Dim db As Database Set db = OpenDatabase(strDb) db.TableDefs.Delete strTbl db.Close: Set db = Nothing End Function '----- ' pour lancer la suppression Call DeleteTableExt(n_BdD, n_tabl) '---- 'pour compter le nbre de champ d'une table distante '---- Function NbDeChamp2(ByVal strDb As String, ByVal strTbl As String) As Integer On Error GoTo err Dim db As DAO.Database Dim tabb As DAO.TableDef Set db = OpenDatabase(strDb) Set tabb = db.TableDefs(strTbl ) NbDeChamp2 = tabb .Fields.Count err: End Function '----- ' pour lancer le comptage MsgBox NbDeChamp2(n_BdD, n_tabl) '----- 'pour déplacer un champ dans une BdD distante '---- Sub deplace_ch_OK(ByVal strBase As String, ByVal strTbl As String, ByVal NchOld As String, ByVal pos As Integer) ' attention le compte commence à 0 On Error GoTo err: Dim db As DAO.Database Dim tabb As DAO.TableDef Dim chp As DAO.Field Set db = OpenDatabase(strBase) Set tabb = db.TableDefs(strTbl) Set chp = tabb.Fields(NchOld) chp.OrdinalPosition = (pos) Exit Sub err: MsgBox "L'action déplacer le champ a échouée" End Sub '---- 'pour lancer le déplacement '---- Call deplace_ch_OK(n_BdD, n_tabl, n_chp, pos) '----
Bon usage Denis
Salut,
"denis le breton" | est il possible de faire un drop table sur une BdD distante ?
' pour renommer une champ sur une table distante
'-----
Public Sub RenommerChampDAO(ByVal strBase As String, ByVal strTbl As String,
ByVal NchOld As String, ByVal NchNew As String)
On Error GoTo err:
Dim db As DAO.Database
Dim tabb As DAO.TableDef
Dim chp As DAO.Field
Set db = OpenDatabase(strBase)
Set tabb = db.TableDefs(strTbl)
Set chp = tabb.Fields(NchOld)
chp.Name = NchNew
Set chp = Nothing
Set tabb = Nothing
Set db = Nothing
Exit Sub
err:
MsgBox "L'action renommer le champ a échouée"
End Sub
'----
'lancement par
Call RenommerChampDAO(n_BdD, n_tabl, n_ch_old, n_ch_new)
'-----
'pour supprimer une table dans une BdD distante
'-----
Public Function DeleteTableExt(ByVal strDb As String, ByVal strTbl As String)
Dim db As Database
Set db = OpenDatabase(strDb)
db.TableDefs.Delete strTbl
db.Close: Set db = Nothing
End Function
'-----
' pour lancer la suppression
Call DeleteTableExt(n_BdD, n_tabl)
'----
'pour compter le nbre de champ d'une table distante
'----
Function NbDeChamp2(ByVal strDb As String, ByVal strTbl As String) As Integer
On Error GoTo err
Dim db As DAO.Database
Dim tabb As DAO.TableDef
Set db = OpenDatabase(strDb)
Set tabb = db.TableDefs(strTbl )
NbDeChamp2 = tabb .Fields.Count
err:
End Function
'-----
' pour lancer le comptage
MsgBox NbDeChamp2(n_BdD, n_tabl)
'-----
'pour déplacer un champ dans une BdD distante
'----
Sub deplace_ch_OK(ByVal strBase As String, ByVal strTbl As String, ByVal
NchOld As String, ByVal pos As Integer)
' attention le compte commence à 0
On Error GoTo err:
Dim db As DAO.Database
Dim tabb As DAO.TableDef
Dim chp As DAO.Field
Set db = OpenDatabase(strBase)
Set tabb = db.TableDefs(strTbl)
Set chp = tabb.Fields(NchOld)
chp.OrdinalPosition = (pos)
Exit Sub
err:
MsgBox "L'action déplacer le champ a échouée"
End Sub
'----
'pour lancer le déplacement
'----
Call deplace_ch_OK(n_BdD, n_tabl, n_chp, pos)
'----
Bon usage
Denis
Salut,
"denis le breton"
| est il possible de faire un drop table sur une BdD distante ?
' pour renommer une champ sur une table distante '----- Public Sub RenommerChampDAO(ByVal strBase As String, ByVal strTbl As String, ByVal NchOld As String, ByVal NchNew As String) On Error GoTo err: Dim db As DAO.Database Dim tabb As DAO.TableDef Dim chp As DAO.Field Set db = OpenDatabase(strBase) Set tabb = db.TableDefs(strTbl) Set chp = tabb.Fields(NchOld) chp.Name = NchNew Set chp = Nothing Set tabb = Nothing Set db = Nothing Exit Sub err: MsgBox "L'action renommer le champ a échouée" End Sub '---- 'lancement par Call RenommerChampDAO(n_BdD, n_tabl, n_ch_old, n_ch_new) '----- 'pour supprimer une table dans une BdD distante '----- Public Function DeleteTableExt(ByVal strDb As String, ByVal strTbl As String) Dim db As Database Set db = OpenDatabase(strDb) db.TableDefs.Delete strTbl db.Close: Set db = Nothing End Function '----- ' pour lancer la suppression Call DeleteTableExt(n_BdD, n_tabl) '---- 'pour compter le nbre de champ d'une table distante '---- Function NbDeChamp2(ByVal strDb As String, ByVal strTbl As String) As Integer On Error GoTo err Dim db As DAO.Database Dim tabb As DAO.TableDef Set db = OpenDatabase(strDb) Set tabb = db.TableDefs(strTbl ) NbDeChamp2 = tabb .Fields.Count err: End Function '----- ' pour lancer le comptage MsgBox NbDeChamp2(n_BdD, n_tabl) '----- 'pour déplacer un champ dans une BdD distante '---- Sub deplace_ch_OK(ByVal strBase As String, ByVal strTbl As String, ByVal NchOld As String, ByVal pos As Integer) ' attention le compte commence à 0 On Error GoTo err: Dim db As DAO.Database Dim tabb As DAO.TableDef Dim chp As DAO.Field Set db = OpenDatabase(strBase) Set tabb = db.TableDefs(strTbl) Set chp = tabb.Fields(NchOld) chp.OrdinalPosition = (pos) Exit Sub err: MsgBox "L'action déplacer le champ a échouée" End Sub '---- 'pour lancer le déplacement '---- Call deplace_ch_OK(n_BdD, n_tabl, n_chp, pos) '----
Bon usage Denis
Salut,
"denis le breton" | est il possible de faire un drop table sur une BdD distante ?