Sql Insert Into

shamas21

Registered User.
Local time
Today, 19:42
Joined
May 27, 2008
Messages
162
Hi All

Im trying to add new records to the 'age' table, but it wont work, what am i doing wrong?

INSERT INTO age ( age, letter )
VALUES ('39', 'Z')
 
Is age numeric? If so, this might work:

Code:
INSERT INTO age ( age, letter )
VALUES (39, 'Z');
 
Hi

this still doesnt work. how do i execute this? currently im pressing the datasheet view button, is this correct?
 
Well, the code you posted is DML, which you would run from an Access query. Since that was what you gave me to work with, that is how I responded. I have no clue what you mean when you say "pressing the datasheet view button" but I can assure you that neither your code nor my code has anything to do with that.

Please open up the query design view, select no tables, select "SQL View", and put the code above in SQL view.

Not sure what you're trying to accomplish here. Unless you are getting data from an external source, you shouldn't even be writing code. Just create a form for entering the data (using the form wizard) and let Access do the hard work.
 
Well, the code you posted is DML, which you would run from an Access query. Since that was what you gave me to work with, that is how I responded. I have no clue what you mean when you say "pressing the datasheet view button" but I can assure you that neither your code nor my code has anything to do with that.

Please open up the query design view, select no tables, select "SQL View", and put the code above in SQL view.

Not sure what you're trying to accomplish here. Unless you are getting data from an external source, you shouldn't even be writing code. Just create a form for entering the data (using the form wizard) and let Access do the hard work.

Hi George

Thanks for your reply. Im trying to learn SQL so i can use it with VBA.

I am using the statement mention previously into the SQL view. I run the query and nothing happens. Im wondering what im doing wrong?
 
Please define "nothing happens". Did you look in the table to see if the data is in the table? If no, how are you running the query? Do you press the red "!"?
 
Please define "nothing happens". Did you look in the table to see if the data is in the table? If no, how are you running the query? Do you press the red "!"?

Yes, when i press the red !, the table still is the same - no records have been added to it. I dont understand why.

p.s. i dont get no error messages either
 
OK, I duplicated your scenario and had the same problem initially. In my case, it is because I'm using Access 2007 and don't have my trust settings set to allow running queries/macros/VB.

Are you "trusting" the database that you're working with? If not, it won't work and won't tell you why.

In 2007, right below the ribbon is typically a button that will allow you to trust content in the current database.

Let me know if that fixes it.
 
OK, I duplicated your scenario and had the same problem initially. In my case, it is because I'm using Access 2007 and don't have my trust settings set to allow running queries/macros/VB.

Are you "trusting" the database that you're working with? If not, it won't work and won't tell you why.

In 2007, right below the ribbon is typically a button that will allow you to trust content in the current database.

Let me know if that fixes it.

Fantastic George, it works perfect now.

Its a shame that Access doesnt give a warning about trust settings, it would have saved alot of time for me. Anyhow, thanks
 
Glad you got it working.

Access does give a warning, they just don't do it so you can see it. Out of all the things I hate about 2007, this is probably the worst and will, no doubt, bite all of us many times for years to come.

A potential long-term solution is to put all of your Access files in one directory and "trust" that directory.
 

Users who are viewing this thread

Back
Top Bottom