C
ChoonBoy
What I am trying to do does not work.
The objective is to reduce the number of queries in database windows.
- Instead of creating a query for another query to use its data
- I hope to use the sql statement within the code to be used by the
DoCmd.RunSQL part.
Something like this (what a mess). Please point me to the right direction.
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set rst = dbs.OpenRecordset( _
"SELECT [expensegrpid] & [ExpenseCategoryID] AS ExpRptName, [Expense
Category].ExpenseGrpID FROM [Expense Category]")
DoCmd.RunSQL "INSERT INTO [Expense Report] ( ExpenseRptName, ExpenseID,
DateSubmitted ) SELECT rst.ExpRptName, rst.ExpenseGrpID, DateValue(Now()) AS
[Date] FROM [Expense Report] RIGHT JOIN rst ON ([Expense
Report].ExpenseRptName = rst.ExpRptName) AND ([Expense Report].ExpenseID =
rst.ExpenseGrpID)WHERE ((([Expense Report].ExpenseReportID) Is Null)); ", -1
Thanks
The objective is to reduce the number of queries in database windows.
- Instead of creating a query for another query to use its data
- I hope to use the sql statement within the code to be used by the
DoCmd.RunSQL part.
Something like this (what a mess). Please point me to the right direction.
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set rst = dbs.OpenRecordset( _
"SELECT [expensegrpid] & [ExpenseCategoryID] AS ExpRptName, [Expense
Category].ExpenseGrpID FROM [Expense Category]")
DoCmd.RunSQL "INSERT INTO [Expense Report] ( ExpenseRptName, ExpenseID,
DateSubmitted ) SELECT rst.ExpRptName, rst.ExpenseGrpID, DateValue(Now()) AS
[Date] FROM [Expense Report] RIGHT JOIN rst ON ([Expense
Report].ExpenseRptName = rst.ExpRptName) AND ([Expense Report].ExpenseID =
rst.ExpenseGrpID)WHERE ((([Expense Report].ExpenseReportID) Is Null)); ", -1
Thanks