Connecting Tech Pros Worldwide Help | Site Map

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

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 10:39 PM
Andy_HR
Guest
 
Posts: n/a
Default I need a little help... INSERT INTO SQL Command

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  
Old November 12th, 2005, 10:39 PM
John Winterbottom
Guest
 
Posts: n/a
Default 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


  #3  
Old November 12th, 2005, 10:39 PM
Andy_HR
Guest
 
Posts: n/a
Default 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 & "'" &
")")


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

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 220,662 network members.