Kitticus_Kattus
New member
- Local time
- Today, 21:17
- Joined
- May 2, 2023
- Messages
- 5
Hi All
I have tried everything i can think of to get around this but i am at a dead end.
I have a report which, for reasons that are annoying and too long to go into, has to be exported into excel as a recordset. The query i am using has gone through many queries in order to get to the finished product of a crosstab query with departments in the columns and dates and pay items as rows. I need the report to filter on the dates in order to get a report which only shows 1 date. For some reason when i try to just use the criteria section of the query i get the error message
"The Microsoft Access database engine does not recognize '[Forms]![Selector]![date]!' as a valid field name or expression"
I believe this is a known bug and nothing i can do (including rewriting the query) seems to get rid of it.
This is the code i am using to get the data into the recordset. I used a Youtube video but apparently i am not allowed to post links until i have 10 posts but i will find a way to send it if you think it will be helpful.
I have tried to apply a filter to the query in the VB code and also in the SQL code and neither seem to work.
Does anyone have any ideas?
Thanks a big ton!
Kitty
I have tried everything i can think of to get around this but i am at a dead end.
I have a report which, for reasons that are annoying and too long to go into, has to be exported into excel as a recordset. The query i am using has gone through many queries in order to get to the finished product of a crosstab query with departments in the columns and dates and pay items as rows. I need the report to filter on the dates in order to get a report which only shows 1 date. For some reason when i try to just use the criteria section of the query i get the error message
"The Microsoft Access database engine does not recognize '[Forms]![Selector]![date]!' as a valid field name or expression"
I believe this is a known bug and nothing i can do (including rewriting the query) seems to get rid of it.
This is the code i am using to get the data into the recordset. I used a Youtube video but apparently i am not allowed to post links until i have 10 posts but i will find a way to send it if you think it will be helpful.
'Dim xlApp as Object
'Dim xlBook as Object
'Dim xlSheet as Object
Dim XlApp As Excel.Application
Dim XLBook As Excel.Workbook
Dim Xlsheet As Excel.Worksheet
Dim SQL As String
Dim SQL2 As String
Dim rs1 As DAO.Recordset
Dim RS2 As DAO.Recordset2
SQL = "SELECT Order, Description, IP, CBI, FXMT, TI, D_S, TAD, FF, LA, CSOE, [GSLS - FO], [GSLS - MO], [OPS - GSLS], ORM, RM, COM, A_T, GAP, [GAP-PCM], IT_DEV, IT_SAS, LEG, SM, [OPS-MGMT], DC, PER, UKAO FROM [Local Personnel Costs] "
Set rs1 = CurrentDb.OpenRecordset(SQL, dbOpenSnapshot)
SQL2 = "SELECT Order, Description, IP, CBI, FXMT, TI, D_S, TAD, FF, LA, CSOE, [GSLS - FO], [GSLS - MO], [OPS - GSLS], ORM, RM, COM, A_T, GAP, [GAP-PCM], IT_DEV, IT_SAS, LEG, SM, [OPS-MGMT], DC, PER, UKAO FROM [Delegate Personnel Costs] "
Set RS2 = CurrentDb.OpenRecordset(SQL2, dbOpenSnapshot)
Set XlApp = Excel.Application
XlApp.Visible = True
Set XLBook = XlApp.Workbooks.Add
Set Xlsheet = XLBook.Worksheets(1)
With Xlsheet
.Name = "PERSONNEL COSTS"
.Cells.Font.Name = "Calibri"
.Cells.Font.Size = 11
[I].[formatting that i am sure you don't need][/I]
For cols = 0 To rs1.Fields.Count - 1
.Cells(3, cols + 1).Value = rs1.Fields(cols).Name
Next
.Range("A4").CopyFromRecordset RS2
.Range("A21").CopyFromRecordset rs1
End With
End Sub
I have tried to apply a filter to the query in the VB code and also in the SQL code and neither seem to work.
Does anyone have any ideas?
Thanks a big ton!
Kitty