I'm building a database with Office 97 (yes, I know it's outdated). To do most of the things I need to do, I will have to use the "INSERT INTO" and "SELECT" statments. The problem is, I can't seem to get either of these to work in code.
I try using the INSERT INTO statments like this: INSERT INTO destination SELECT source.field FROM source WHERE field = x
For example:
INSERT INTO([Cancelled Customers]) SELECT [Current Customers].[Customer ID] FROM [Current Customers] WHERE [Customer ID] = x
That is all one line.
If I put it all on one line like the reference file says, I get an error because the compiler expected "end of statment" right before "SELECT".
I also tried it on seperate lines, like this:
INSERT INTO([Cancelled Customers])
SELECT [Current Customers].[Customer ID]
FROM [Current Customers]
WHERE [Customer ID] = x
If I do that, three of the lines work fine, except the SELECT line does something odd. I get a compliler error that says "expected: case" right after "SELECT", as if I was using the "Select Case" statment rather than the SELECT statment.
This doesn't just happen when using the INSERT INTO statment. Anytime I try to use the SELECT statment, even on it's own, the compliler thinks I'm actually meaning to use the Select Case statment.
Basically, I would like to know the proper way to do a INSERT INTO and a SELECT statment in Microsoft Access 97 (using VBA). Although upgrading MS Office would probably provide me with an easier way to accomplish what I need to, I know it is possible in Access 97, because it is in the help file, I guess I just can't get the syntax right.
Thanks for any help. I'm somewhat new to programming, and while I have a general understanding of how it works, there are some statments like this one that I just can't get to work. Any help would be greatly appreciated.
Thanks!
I try using the INSERT INTO statments like this: INSERT INTO destination SELECT source.field FROM source WHERE field = x
For example:
INSERT INTO([Cancelled Customers]) SELECT [Current Customers].[Customer ID] FROM [Current Customers] WHERE [Customer ID] = x
That is all one line.
If I put it all on one line like the reference file says, I get an error because the compiler expected "end of statment" right before "SELECT".
I also tried it on seperate lines, like this:
INSERT INTO([Cancelled Customers])
SELECT [Current Customers].[Customer ID]
FROM [Current Customers]
WHERE [Customer ID] = x
If I do that, three of the lines work fine, except the SELECT line does something odd. I get a compliler error that says "expected: case" right after "SELECT", as if I was using the "Select Case" statment rather than the SELECT statment.
This doesn't just happen when using the INSERT INTO statment. Anytime I try to use the SELECT statment, even on it's own, the compliler thinks I'm actually meaning to use the Select Case statment.
Basically, I would like to know the proper way to do a INSERT INTO and a SELECT statment in Microsoft Access 97 (using VBA). Although upgrading MS Office would probably provide me with an easier way to accomplish what I need to, I know it is possible in Access 97, because it is in the help file, I guess I just can't get the syntax right.
Thanks for any help. I'm somewhat new to programming, and while I have a general understanding of how it works, there are some statments like this one that I just can't get to work. Any help would be greatly appreciated.
Thanks!