Sara Kannaoui
Sara Kannaoui

Reputation: 13

syntax error at insert into

i need to insert some informations from a form to a table fields, i tried this code:

Dim sql As String

sql = " insert into récapRELAIS( Région, Groupe, Agence, N°personne, 
    Nom du client, N°prêt, Durée, Nature du prêt, Encours client) 
    Values (" 
    & Me.Region & "  , " & Me.Groupe & " , " 
    & Me.Agence & " , " & Me.Num_Personne & " , " 
    & Me.Nom_client & " , " & Me.Num_Contrat & " , " 
    & Me.Montant_prêt & ", " & Me.Durée_prêt & " ," 
    & Me.Nature_prêt & " , " & Me.Encours & "); "

DoCmd.RunSQL sql

but it doesn't work, it says that i have an error type 3134

Upvotes: 1

Views: 45

Answers (1)

SQL Police
SQL Police

Reputation: 4206

The problem are most likely your field names with spaces.

Solution: Surround with square brackets - [ ], like this:

insert into récapRELAIS( Région, Groupe, Agence, [N°personne], 
[Nom du client], [N°prêt], Durée, [Nature du prêt], [Encours client]) 

I am also not sure if the ° sign is working.

In general, I advice you to not take spaces or special characters or diacritics like ê è é for database field names.

Formatting and pretty display should take place in the user interface; but the database is more a programming environment, and there, it's better to just use the basic characters A-Z and 0-9.

Upvotes: 1

Related Questions