Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 8th, 2007, 03:27 PM
Authorized User
 
Join Date: Nov 2006
Location: Evergreen, CO, USA.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default INSERT SQL

Does anybody know a good reference to Access SQL? Preferably online.

I'm getting an error message Syntax Error in INSERT INTO Statement.

Here's the code: it works down to the RunSQL statement. Probably I'm overlooking something, but can't find a reference.
Note: there's no line break after Startdate,, the forum just shortened the line.
-------------------------------
Private Sub cmdAddRecord1_Click()
On Error GoTo Err_cmdAddRecord1_Click
    Dim txtSQLAdd As String
    txtSQLAdd = "INSERT INTO Registration ShortName, StartDate, Email, First, Last " & _
        "VALUES (lstShortNameS, lstStartDateS, txtEmailS, txtFirstS, txtLastS);"
    txtFirstS = Forms![Update Registrations].txtFirst
    txtLastS = Forms![Update Registrations].txtLast
    txtEmailS = Forms![Update Registrations].txtEmail
    txtGo = MsgBox("OK to Update?", 1, "Is All Data Correct")
    If txtGo = vbOK Then
        txtAction = "Update"
        DoCmd.RunSQL txtSQLAdd
    Else
        txtAction = "Cancel"
        Me.Undo
    End If

Reply With Quote
  #2 (permalink)  
Old February 8th, 2007, 09:51 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Yorba Linda, California, USA.
Posts: 217
Thanks: 0
Thanked 1 Time in 1 Post
Default

Don,

It looks like you are missing a set of parentheses. Try this:

txtSQLAdd = "INSERT INTO Registration (ShortName, StartDate, Email, First, Last) "



BTW- you are inserting EVERYTHING- hence no "WHERE" clause, right?

HTH,

Loralee

Reply With Quote
  #3 (permalink)  
Old February 9th, 2007, 06:37 PM
Authorized User
 
Join Date: Nov 2006
Location: Evergreen, CO, USA.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Loralee:
You are correct about the parentheses. After I posted the message, I found syntax for INSERT in my WROX SQL Server book.

There's no WHERE in the INSERT statement. It's taking values from text boxes in the form. This form allows the user to browse through the People table, select a person, and add their information to a class registration table. I'm still polishing it.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Insert kavithaganesh SQL Language 1 September 26th, 2007 11:20 PM
SQL Insert C# N4th SQL Server 2000 6 December 5th, 2006 05:28 AM
how to create insert sql aji SQL Language 4 June 23rd, 2005 06:41 PM
how to insert into SQL table p2ptolu Classic ASP Databases 1 June 17th, 2005 06:52 AM
SQL INSERT mattastic Classic ASP Databases 3 February 24th, 2005 07:56 AM



All times are GMT -4. The time now is 03:10 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.