rtdc
Registered User.
- Local time
- Today, 16:54
- Joined
- Feb 27, 2007
- Messages
- 55
I have spend hours trying to work this out and either to thick, rusting or its very hard 
What I want to do is take the result form a sql query in vba and append it to a pre-existing table with the same field names as used in the sql.
My SQL query is
Srch = built on a form and in this example = [Car List]![Make], [Car List]![Model], [Car List]![Transmission] though it could be any combination of many fields
WHE = built on a form and in this example = [Car List]![Colour(s)]) = "Red" though it could be anything suitable for a where statement
T1 is the table Car List and looked up
Set RS = CurrentDb.OpenRecordset("SELECT " & Srch & " FROM " & T1 & " WHERE (((" & WHE & " ))")
This works and returns: -
Volvo 144 Auto Manual
Renault 15 Manual
BMW 525 Auto
Renault 5 Manual
Rover SD1 Manual
Ford P100 Manual
Vauxhall Chevette Manual
Ford Fiesta Manual
Nissan Micra Manual
Nissan Micra Manual
During the on form building of this query a table called Temp was created with the fields (in this example) Make, Model, Transmission.
I can export this successfully to excel where I can see the full result of the query but what I want to do is append this result to the Temp table. I have looked on here and other sites and either I have not found the answer or missed it.
Any ideas on how to do this, if it is possible that is?
What I want to do is take the result form a sql query in vba and append it to a pre-existing table with the same field names as used in the sql.
My SQL query is
Srch = built on a form and in this example = [Car List]![Make], [Car List]![Model], [Car List]![Transmission] though it could be any combination of many fields
WHE = built on a form and in this example = [Car List]![Colour(s)]) = "Red" though it could be anything suitable for a where statement
T1 is the table Car List and looked up
Set RS = CurrentDb.OpenRecordset("SELECT " & Srch & " FROM " & T1 & " WHERE (((" & WHE & " ))")
This works and returns: -
Volvo 144 Auto Manual
Renault 15 Manual
BMW 525 Auto
Renault 5 Manual
Rover SD1 Manual
Ford P100 Manual
Vauxhall Chevette Manual
Ford Fiesta Manual
Nissan Micra Manual
Nissan Micra Manual
During the on form building of this query a table called Temp was created with the fields (in this example) Make, Model, Transmission.
I can export this successfully to excel where I can see the full result of the query but what I want to do is append this result to the Temp table. I have looked on here and other sites and either I have not found the answer or missed it.
Any ideas on how to do this, if it is possible that is?