I need a little help... INSERT INTO SQL Command
Question posted by: Andy_HR
(Guest)
on
November 12th, 2005 11:39 PM
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
2
Answers Posted
"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
"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 & "'" &
")")
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 196,901 network members.
Top Community Contributors
|