Results 1 to 3 of 3
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    INSERT statement

    I have a simple table that I want to initialize. However, I get an error message "Too few paramaters. Expected 1." with the following code. I'm expecting the remaining table fields to simply default according to their field attributes. FIELDS: "RoomNumber" plus One autonumber field, one number field and four text fields.

    Private Sub InitRooms()
    Dim I As Integer

    For I = 1 To 1000
    CurrentDb.Execute "INSERT INTO tblRooms (RoomNumber) VALUES (I);"
    Next I

    End Sub

    What am I missing here?
    Thanks,
    Bill

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Must concatenate variable otherwise the value trying to save is the literal alpha character 'I';

    CurrentDb.Execute "INSERT INTO tblRooms (RoomNumber) VALUES (" & I & ");"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Ah yes! I see.
    Thanks,
    Bill

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 03-09-2013, 10:44 AM
  2. Insert Into statement
    By TimMoffy in forum Programming
    Replies: 7
    Last Post: 07-13-2012, 07:10 AM
  3. Insert statement
    By crowegreg in forum Programming
    Replies: 2
    Last Post: 08-19-2011, 02:20 PM
  4. Help about access INSERT INTO statement
    By ducthang88 in forum Programming
    Replies: 7
    Last Post: 12-03-2010, 08:40 AM
  5. Replies: 4
    Last Post: 09-03-2010, 02:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums