Reputation: 689
I have a query in MS ACCESS, I ran it in MS ACCESS:
SELECT * FROM table1
INNER JOIN table2 ON table1.f1=table2.f1 WHERE table1.f2=table2.f2
It works fine. However, I need to save the results into another table. So, I changed it to:
SELECT * Into a1
FROM table1 INNER JOIN table2 ON table1.f1=table2.f1 WHERE table1.f2=table2.f2
It does not work. I receive this error: "Cannot Open database. It may not be a database that your application recognizes, or the file may be corrupt." Does anybody know how I can save the results in a database or txt file?
Thank you very much.
Upvotes: 0
Views: 641
Reputation: 832
try create a new table with the values mentioned at your select.
step 1:
CREATE TABLE table_shadi
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
....
)
make sure you defined the same datatypes and number of fields as expected from you query
step 2:
Insert into table_shadi(column_name1,column_name2,column_name3)
SELECT column_name1,column_name2,column_name3
FROM table1
INNER JOIN table2
ON table1.f1=table2.f1
WHERE table1.f2=table2.f2
Hope it helps.
Upvotes: 0
Reputation: 13581
You can easily output the results as a .txt file or a .csv file (that you can view in Excel). To export a .txt file:
DoCmd.TransferText acExportDelim, , "myQuery", "C:\myQuery.txt", True
You can research TransferText in help to see the options for a .csv file.
This should work easily.
Upvotes: 1
Reputation: 74350
Is the database read-only?
Some things to check:
Is the DB file's read-only attribute set?
Did you use "Open Read Only" to open the DB?
Are you out of disk space?
Is there enough disk space to create the new table?
Upvotes: 1
Reputation: 65381
You can use the insert into command, see: http://msdn.microsoft.com/en-us/library/bb208861(office.12).aspx
Also appears that the database is in read only mode.
Upvotes: 1