Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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

  #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

  #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.



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





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