Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Nom de champ en VBA

4 réponses
Avatar
Michel B
Bonjours a tous,

Je souhaite créer une table avec 4 champs, mais ne sais pas comment on
sépare les champs en VBA :

CREATE TABLE ([N°Adherent] LONG , [N°Structure] LONG , [Actif] CBoll
,[Saison] Str )

Quelques explications serait le bienvenue

D'avance merci
Michel

4 réponses

Avatar
Gilbert
Bonjour,

Extrait de l'aide d'Access :
Exemples avec CREATE TABLE (instruction) et CONSTRAINT (clause)

Cet exemple crée une nouvelle table nommée ThisTable comportant deux champs
text.

Sub CreateTableX1()


Dim dbs As Database


' Modify this line to include the path to Northwind

' on your computer.

Set dbs = OpenDatabase(".mdb")


' Create a table with two text fields.

dbs.Execute "CREATE TABLE ThisTable " _

& "(FirstName CHAR, LastName CHAR, " _


dbs.Close


End Sub


Cet exemple crée une nouvelle table nommée MyTable comportant deux champs
text, un champ Date/Time et un index unique composé des trois champs

Sub CreateTableX2()


Dim dbs As Database


' Modify this line to include the path to Northwind

' on your computer.

Set dbs = OpenDatabase(".mdb")


' Create a table with three fields and a unique

' index made up of all three fields.

dbs.Execute "CREATE TABLE MyTable " _

& "(FirstName CHAR, LastName CHAR, " _

& "[DateOfBirth] DATETIME, " _

& "CONSTRAINT MyTableConstraint UNIQUE " _

& "(FirstName, LastName, [DateOfBirth]));"


dbs.Close


End Sub


Cet exemple crée une nouvelle table comportant deux champs text et un champ
integer. Le champ SSN constitue la clé primaire.

Sub CreateTableX3()


Dim dbs As Database


' Modify this line to include the path to Northwind

' on your computer.

Set dbs = OpenDatabase(".mdb")


' Create a table with three fields and a ^primary

' key.

dbs.Execute "CREATE TABLE NewTable " _

& "(FirstName CHAR, LastName CHAR, " _

& "SSN INTEGER CONSTRAINT MyFieldConstraint " _

& "PRIMARY KEY);"


dbs.Close


End Sub


--
Cordialement,

Gilbert


"Michel B" a écrit dans le message de
news:485a0df8$0$4533$

Bonjours a tous,

Je souhaite créer une table avec 4 champs, mais ne sais pas comment on
sépare les champs en VBA :

CREATE TABLE ([N°Adherent] LONG , [N°Structure] LONG , [Actif] CBoll
,[Saison] Str )

Quelques explications serait le bienvenue

D'avance merci
Michel




Avatar
Michel B
Bonjour Gilbert,

Merci pour ton aide

J'ai fait cela et ça fonctionne bien, jusqu'a "Saison" en revanche "Actif "
qui doit être un champ Oui/Non génére une erreur.
Je ne trouve pas dans l'aide la syntaxe a utiliser pour les différents type
de champs


Dim dbs As Database
Set dbs = OpenDatabase("C:BaseBase2003.mdb")
dbs.Execute "CREATE TABLE Mutations (N°Adherent LONG, N°Structure
LONG, Saison CHAR, Actif BOOL) "
dbs.Close

Encore merci
Michel


"Gilbert" a écrit dans le message de news:
%
Bonjour,

Extrait de l'aide d'Access :
Exemples avec CREATE TABLE (instruction) et CONSTRAINT (clause)

Cet exemple crée une nouvelle table nommée ThisTable comportant deux
champs
text.

Sub CreateTableX1()


Dim dbs As Database


' Modify this line to include the path to Northwind

' on your computer.

Set dbs = OpenDatabase(".mdb")


' Create a table with two text fields.

dbs.Execute "CREATE TABLE ThisTable " _

& "(FirstName CHAR, LastName CHAR, " _


dbs.Close


End Sub


Cet exemple crée une nouvelle table nommée MyTable comportant deux champs
text, un champ Date/Time et un index unique composé des trois champs

Sub CreateTableX2()


Dim dbs As Database


' Modify this line to include the path to Northwind

' on your computer.

Set dbs = OpenDatabase(".mdb")


' Create a table with three fields and a unique

' index made up of all three fields.

dbs.Execute "CREATE TABLE MyTable " _

& "(FirstName CHAR, LastName CHAR, " _

& "[DateOfBirth] DATETIME, " _

& "CONSTRAINT MyTableConstraint UNIQUE " _

& "(FirstName, LastName, [DateOfBirth]));"


dbs.Close


End Sub


Cet exemple crée une nouvelle table comportant deux champs text et un
champ
integer. Le champ SSN constitue la clé primaire.

Sub CreateTableX3()


Dim dbs As Database


' Modify this line to include the path to Northwind

' on your computer.

Set dbs = OpenDatabase(".mdb")


' Create a table with three fields and a ^primary

' key.

dbs.Execute "CREATE TABLE NewTable " _

& "(FirstName CHAR, LastName CHAR, " _

& "SSN INTEGER CONSTRAINT MyFieldConstraint " _

& "PRIMARY KEY);"


dbs.Close


End Sub


--
Cordialement,

Gilbert


"Michel B" a écrit dans le message de
news:485a0df8$0$4533$

Bonjours a tous,

Je souhaite créer une table avec 4 champs, mais ne sais pas comment on
sépare les champs en VBA :

CREATE TABLE ([N°Adherent] LONG , [N°Structure] LONG , [Actif] CBoll
,[Saison] Str )

Quelques explications serait le bienvenue

D'avance merci
Michel








Avatar
Gilbert
As-tu essayé avec BOOLEAN?

--
Cordialement,

Gilbert


"Michel B" a écrit dans le message de
news:485a2c43$0$19721$
Bonjour Gilbert,

Merci pour ton aide

J'ai fait cela et ça fonctionne bien, jusqu'a "Saison" en revanche "Actif


"
qui doit être un champ Oui/Non génére une erreur.
Je ne trouve pas dans l'aide la syntaxe a utiliser pour les différents


type
de champs


Dim dbs As Database
Set dbs = OpenDatabase("C:BaseBase2003.mdb")
dbs.Execute "CREATE TABLE Mutations (N°Adherent LONG, N°Structure
LONG, Saison CHAR, Actif BOOL) "
dbs.Close

Encore merci
Michel


"Gilbert" a écrit dans le message de news:
%
> Bonjour,
>
> Extrait de l'aide d'Access :
> Exemples avec CREATE TABLE (instruction) et CONSTRAINT (clause)
>
> Cet exemple crée une nouvelle table nommée ThisTable comportant deux
> champs
> text.
>
> Sub CreateTableX1()
>
>
> Dim dbs As Database
>
>
> ' Modify this line to include the path to Northwind
>
> ' on your computer.
>
> Set dbs = OpenDatabase(".mdb")
>
>
> ' Create a table with two text fields.
>
> dbs.Execute "CREATE TABLE ThisTable " _
>
> & "(FirstName CHAR, LastName CHAR, " _
>
>
> dbs.Close
>
>
> End Sub
>
>
> Cet exemple crée une nouvelle table nommée MyTable comportant deux


champs
> text, un champ Date/Time et un index unique composé des trois champs
>
> Sub CreateTableX2()
>
>
> Dim dbs As Database
>
>
> ' Modify this line to include the path to Northwind
>
> ' on your computer.
>
> Set dbs = OpenDatabase(".mdb")
>
>
> ' Create a table with three fields and a unique
>
> ' index made up of all three fields.
>
> dbs.Execute "CREATE TABLE MyTable " _
>
> & "(FirstName CHAR, LastName CHAR, " _
>
> & "[DateOfBirth] DATETIME, " _
>
> & "CONSTRAINT MyTableConstraint UNIQUE " _
>
> & "(FirstName, LastName, [DateOfBirth]));"
>
>
> dbs.Close
>
>
> End Sub
>
>
> Cet exemple crée une nouvelle table comportant deux champs text et un
> champ
> integer. Le champ SSN constitue la clé primaire.
>
> Sub CreateTableX3()
>
>
> Dim dbs As Database
>
>
> ' Modify this line to include the path to Northwind
>
> ' on your computer.
>
> Set dbs = OpenDatabase(".mdb")
>
>
> ' Create a table with three fields and a ^primary
>
> ' key.
>
> dbs.Execute "CREATE TABLE NewTable " _
>
> & "(FirstName CHAR, LastName CHAR, " _
>
> & "SSN INTEGER CONSTRAINT MyFieldConstraint " _
>
> & "PRIMARY KEY);"
>
>
> dbs.Close
>
>
> End Sub
>
>
> --
> Cordialement,
>
> Gilbert
>
>
> "Michel B" a écrit dans le message de
> news:485a0df8$0$4533$
>>
>> Bonjours a tous,
>>
>> Je souhaite créer une table avec 4 champs, mais ne sais pas comment on
>> sépare les champs en VBA :
>>
>> CREATE TABLE ([N°Adherent] LONG , [N°Structure] LONG , [Actif] CBoll
>> ,[Saison] Str )
>>
>> Quelques explications serait le bienvenue
>>
>> D'avance merci
>> Michel
>>
>>
>
>




Avatar
3stone
Salut,

"Michel B"
| Je souhaite créer une table avec 4 champs, mais ne sais pas comment on
| sépare les champs en VBA :
|
| CREATE TABLE ([N°Adherent] LONG , [N°Structure] LONG , [Actif] CBoll
| ,[Saison] Str )
|
| Quelques explications serait le bienvenue


Regarde ceci :
http://www.3stone.be/access/articles.php?lng=fr&pg&

--
A+
Pierre (3stone) Access MVP
Perso: http://www.3stone.be/
MPFA: http://www.mpfa.info/ (infos générales)