Connecting Tech Pros Worldwide Help | Site Map

I need a little help... INSERT INTO SQL Command

Andy_HR
Guest
 
Posts: n/a
#1: Nov 12 '05
i have a table named tblClanovi
now i would like to make a sql insert into command that will add new record
in the database...

Private Sub btnSpremi_Click()
Dim broj
Dim imepr
broj = Nz(DMax("ClanID", "tblClanovi")) + 1
Me!txtClanBroj = broj
imepr = Me!txtImePrezime
DoCmd.RunSQL "INSERT INTO tblClanovi (ClanID, ImePrezime) VALUES " & broj &
imepr
End Sub

can you help me.. i get
Run-Time error '3134':
Syntax error in INSERT INTO statement

-
Andy


John Winterbottom
Guest
 
Posts: n/a
#2: Nov 12 '05

re: I need a little help... INSERT INTO SQL Command


"Andy_HR" <andy_no_spam_here@remove_this_xnet.hr> wrote in message
news:c7lets$10h$1@brown.net4u.hr...[color=blue]
> i have a table named tblClanovi
> now i would like to make a sql insert into command that will add new[/color]
record[color=blue]
> in the database...
>
> Private Sub btnSpremi_Click()
> Dim broj
> Dim imepr
> broj = Nz(DMax("ClanID", "tblClanovi")) + 1
> Me!txtClanBroj = br
> imepr = Me!txtImePrezime
> DoCmd.RunSQL "INSERT INTO tblClanovi (ClanID, ImePrezime) VALUES " & broj[/color]
&[color=blue]
> imepr
> End Sub
>[/color]

DoCmd.RunSQL "INSERT INTO tblClanovi (ClanID, ImePrezime) VALUES (" & broj
&
"," & imepr & ")"

If either of the column datatypes are text datatypes you will also need to
surround them with single quotes


Andy_HR
Guest
 
Posts: n/a
#3: Nov 12 '05

re: I need a little help... INSERT INTO SQL Command



"John Winterbottom" <assaynet@hotmail.com> wrote in message[color=blue]
> "Andy_HR" <andy_no_spam_here@remove_this_xnet.hr> wrote in message[color=green]
> > i have a table named tblClanovi
> > now i would like to make a sql insert into command that will add new[/color]
> record[color=green]
> > in the database...
> >
> > Private Sub btnSpremi_Click()
> > Dim broj
> > Dim imepr
> > broj = Nz(DMax("ClanID", "tblClanovi")) + 1
> > Me!txtClanBroj = br
> > imepr = Me!txtImePrezime
> > DoCmd.RunSQL "INSERT INTO tblClanovi (ClanID, ImePrezime) VALUES " &[/color][/color]
broj[color=blue]
> &[color=green]
> > imepr
> > End Sub
> >[/color]
>
> DoCmd.RunSQL "INSERT INTO tblClanovi (ClanID, ImePrezime) VALUES (" &[/color]
broj[color=blue]
> &
> "," & imepr & ")"
>
> If either of the column datatypes are text datatypes you will also need to
> surround them with single quotes[/color]

tnx its working now :-)

its working... and then i tryed something else and it works.. here it is..

DoCmd.RunSQL ("INSERT INTO tblClanovi (ClanID, ImePrezime) VALUES (" &
Nz(DMax("ClanID", "tblClanovi")) + 1 & "," & "'" & Me!txtImePrezime & "'" &
")")


Closed Thread