By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,458 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

Problem of Parameters in INSERT Query

P: 11
While running a query (in MS Access 2007), the code of which is
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tbl_Resource_Master ( Resource_Last_Name, Resource_First_Name, Resource_Middle_Name, Resource_Mobile_Number )
  2. VALUES ( '[Resource Last Name]', '[Resource First Name]', '[Resource Middle Name]', [Resource Mobile] );
, it's prompting for the number field only.

Can you please help me on this?
Mar 6 '10 #1

✓ answered by TheSmileyCoder

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tbl_Resource_Master ( Resource_Last_Name, Resource_First_Name, Resource_Middle_Name, Resource_Mobile_Number ) 
  2. VALUES ( '[Resource Last Name]', '[Resource First Name]', '[Resource Middle Name]', [Resource Mobile] );
I don't know what you think your trying to accomplish with your SQL statement, but I can tell you what it will do.
It will insert the STRING "[Resource Last Name]", not values from a field called [Resource Last Name] (same for the next 2 fields). The reason why its only asking for the number field, is because thats the only field you have not enclosed in single quotes.

If your trying to transfer values from one table to another, you will need to include a FROM statement in your SQL. Where is access supposed to take the values from?

Share this Question
Share on Google+
2 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tbl_Resource_Master ( Resource_Last_Name, Resource_First_Name, Resource_Middle_Name, Resource_Mobile_Number ) 
  2. VALUES ( '[Resource Last Name]', '[Resource First Name]', '[Resource Middle Name]', [Resource Mobile] );
I don't know what you think your trying to accomplish with your SQL statement, but I can tell you what it will do.
It will insert the STRING "[Resource Last Name]", not values from a field called [Resource Last Name] (same for the next 2 fields). The reason why its only asking for the number field, is because thats the only field you have not enclosed in single quotes.

If your trying to transfer values from one table to another, you will need to include a FROM statement in your SQL. Where is access supposed to take the values from?
Mar 6 '10 #2

P: 11
Well, your answer
The reason why its only asking for the number field, is because thats the only field you have not enclosed in single quotes.
provided me with the solution. :)

The code that worked were
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tbl_Resource_Master ( Resource_Last_Name, Resource_First_Name, Resource_Middle_Name, Resource_Mobile_Number )
  2. VALUES (['Resource Last Name'], ['Resource First Name'], ['Resource Middle Name'], [Resource Mobile]);
The single quotes should have been inside square braces, in stead of outside those.

And, what I tried to achieve was to insert three values into the table "tbl_Resource_Master", either running the query directly or executing it from the VBA code, both of which produced same result.

Thanks a lot.
Mar 6 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.