itchyII
MIS
- Apr 10, 2001
- 167
Hello All,
I have been asked to automate (in order to run as scheduled task) a multistep process in an Access application. The application was built entirely using the Access gui with about 50 queries and 50 tables. There are a series of queries that must be run and those queries call other queries and so forth. The problem I am having is that I have been asked to do this as quickly as possible and I do not have time to convert all the access queries to code. So, I have an access make table query, that calls another query that requires a parameter. I need to run the queries automatically and pass the parameter as a variable that is passed to my function. And I need to do all of this using ADO (They are in an Access 2000 environment and will be migrating to 2003 shortly). I am not very fast and familiar with ADO. I tried simply taking the sql from the query (the second one) and tried to create a recordset, just to see if the parameter prompt would show up, but it doesn't and I get an error saying "Syntax error in INSERT INTO statement".
I have been asked to automate (in order to run as scheduled task) a multistep process in an Access application. The application was built entirely using the Access gui with about 50 queries and 50 tables. There are a series of queries that must be run and those queries call other queries and so forth. The problem I am having is that I have been asked to do this as quickly as possible and I do not have time to convert all the access queries to code. So, I have an access make table query, that calls another query that requires a parameter. I need to run the queries automatically and pass the parameter as a variable that is passed to my function. And I need to do all of this using ADO (They are in an Access 2000 environment and will be migrating to 2003 shortly). I am not very fast and familiar with ADO. I tried simply taking the sql from the query (the second one) and tried to create a recordset, just to see if the parameter prompt would show up, but it doesn't and I get an error saying "Syntax error in INSERT INTO statement".
Code:
Function step1(SO As String) As ADODB.Recordset
Dim rs As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim sql As String
Set cnn = CurrentProject.Connection
Set rs = CreateObject("ADODB.recordset")
sql = "INSERT INTO POs per SO With AC SELECT [POs per SO average cost with Add Charges Step 1a].PartKey, [POs per SO average cost with Add Charges Step 1a].Partnumber, Avg([POs per SO average cost with Add Charges Step 1a].[Total Cost Incl AC]) AS [SumOfTotal Cost Incl AC] INTO [POs per SO With AC] " _
& "FROM [POs per SO average cost with Add Charges Step 1a] GROUP BY [POs per SO average cost with Add Charges Step 1a].PartKey, [POs per SO average cost with Add Charges Step 1a].Partnumber;"
rs.Open sql, cnn
end function
[\code]
I have tried simply calling the existing function substituting:
rs.Open sql, cnn
with:
rs.Open "POs per SO average cost with Add Charges Step 1b", cnn
and I get anothere error "Invalid SQL statement, expected 'DELETE','INSERT','PROCEDURE",'SELECT',or 'UPDATE'"
And now this is where I'm at!
Help please!
ItchyII