Results 1 to 5 of 5
  1. #1
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115

    Inserting Issues.

    Hi. I am being dumb and I just can see what I am sure is a simple issue. Sorry in advance. I am trying to help my son with his school project which requires demonstrating SQL coding. I have created a table using SQL (Access DB set to SQL standard):

    Code:
    CREATE TABLE  Customer(CustomerEmail  VARCHAR(30)  NOT NULL,        CustomerFirstname         VARCHAR(20)  NOT NULL,CustomerLastname VARCHAR(20)  NOT NULL,        CustomerTel     VARCHAR(20), HouseNoName     VARCHAR(15)  NOT NULL,PostCode     VARCHAR(6)  NOT NULL,City     VARCHAR(30)  NOT NULL,County     VARCHAR(20) ,Country     VARCHAR(15)  NOT NULL,CustomerAge      INTEGERCustomerType     CHAR(2)  NOT NULLCONSTRAINT CUSTPK PRIMARY KEY(CustomerEmail), CONSTRAINT CUSTTPE  FOREIGN KEY(CustomerTypeREFERENCES CustomerType(CustomerTypeON  UPDATE CASCADE ON DELETE CASCADE); 


    This seems to create the table fine. I can manually enter the data into each field in the datasheet view in Access.

    Now I am trying to insert data using SQL. I find some of the fields are accepted but others think the contents are labels and asks me to enter the data at run time. I cant figure out why. I have put various different formats to try to see what causes some fields to work and other not to work but I am really at a loss as some work fine and the same formatting makes other not work!. The test insert is:

    Code:
    INSERT INTO CUSTOMERVALUES (Chr$(39) & tonyggatuk.co.uk Chr$(39), Tony Grant, 01234567889, '85''AL 1234''Bister''herts''uk'52WK); 
    I find fields 1 to 3 at run time it asks me to enter the data in a pop up. 4 - 10 are populated correctly and field 11 is again requesting data in a pop up. I dont understand why for example field 3 is treated differently than field 4? Any help in explaining what is going on would greatly be appreciated.

    MANY THANKS

    Tony

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I always specify the fields in the table, but I think that's optional. You need a space before VALUES and I'd just use the single quotes around the email address. You also need them around any other text values (based on the data type in the table)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    this usu means you got something out of order, or misspelled.
    the params get asked because the field doesnt exist, so access asks for the param.
    try building a query. This can help a lot with errors.

  4. #4
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    This is how I'd write it (without line continuation characters)
    Code:
    INSERT INTO CUSTOMER ([CustomerEmail], [CustomerFirstname], [CustomerLastname], [CustomerTel], [HouseNoName], [PostCode], 
    [City], [County], [Country], [CustomerAge], [CustomerType] VALUES 
    ('tonyggatuk.co.uk', 'Tony', 'Grant', '01234567889', '85', 'AL 1234', 'Bister', 'herts', 'uk', 52, 'WK');
    I agree with Paul's 3 points but also - if your intent is simply to populate this table with this query, I suspect it will not work. You have imposed a relational constraint in the table, which should mean you can UPDATE, but I don't think you can APPEND.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115
    Thank you all. That seemed to fix the issue

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

Similar Threads

  1. Inserting a Calendar
    By pharrison74 in forum Reports
    Replies: 4
    Last Post: 03-01-2016, 12:03 PM
  2. inserting .wav sound?
    By dada in forum Programming
    Replies: 2
    Last Post: 08-20-2010, 11:25 PM
  3. error on inserting value
    By dada in forum Programming
    Replies: 3
    Last Post: 08-18-2010, 11:28 PM
  4. Inserting/Updating
    By detlion1643 in forum Access
    Replies: 1
    Last Post: 02-26-2010, 07:25 PM
  5. Inserting a picture
    By Carenas in forum Forms
    Replies: 0
    Last Post: 01-03-2009, 05:09 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