Hi all.......
I am having a problem that I am guessing has a simple solution. I am using some simple vb code on the "OnClick" event of a button to export a query to excel. Works great. Now I created a crosstab query based on the original query to summarize some info and want to export that to excel. However access has a problem with my ApplyFilter code and I can't figure out what the problem is. All the necessary fields appear to be present and all I did was change the query being exported. I tried to attach a sample database with 1 record (A2k)but at 135 kb it is still to big (any suggestions). The code I'm using is:
This one works:
==============
Private Sub exprtSSVeg_Click()
On Error GoTo exprtSSVeg_Err
DoCmd.Echo False, "The Application is Running. Be Patient!"
DoCmd.OpenQuery "qryGISExprtSSVeg", acNormal, acEdit
DoCmd.ApplyFilter "", "[qryGISExprtSSVEG]![DSSV-Project#]=[Forms]![Data Survey History]![DSH-Project#]"
DoCmd.OutputTo acQuery, "", "MicrosoftExcel(*.xls)", "", True, ""
DoCmd.Close acQuery, "qryGISExprtSSVeg"
DoCmd.Echo True, ""
exprtSSVeg_Exit:
Exit Sub
exprtSSVeg_Err:
MsgBox Error$
Resume exprtSSVeg_Exit
End Sub
This one doesn't: The bold are is what Access is choking on. Error message reads:The Microsoft Jet database engine doesn't recognize '[Forms]![Data Survey History]![DSH-Project#]' as a valid field name or expression.
===================
Private Sub exprtCrsTab_Click()
On Error GoTo exprtCrsTab_Err
DoCmd.Echo False, "The Application is Running. Be Patient!"
DoCmd.OpenQuery "qryGISExprtCT2", acNormal, acEdit
DoCmd.ApplyFilter "", "[qryGISExprtCT2]![DSSV-Project#]=[Forms]![Data Survey History]![DSH-Project#]"
DoCmd.OutputTo acQuery, "", "MicrosoftExcel(*.xls)", "", True, ""
DoCmd.Close acQuery, "qryGISExprtCT2"
DoCmd.Echo True, ""
exprtCrsTab_Exit:
Exit Sub
exprtCrsTab_Err:
MsgBox Error$
Resume exprtCrsTab_Exit
End Sub
Any help is greatly appreciated.
Thanks......Steve
I am having a problem that I am guessing has a simple solution. I am using some simple vb code on the "OnClick" event of a button to export a query to excel. Works great. Now I created a crosstab query based on the original query to summarize some info and want to export that to excel. However access has a problem with my ApplyFilter code and I can't figure out what the problem is. All the necessary fields appear to be present and all I did was change the query being exported. I tried to attach a sample database with 1 record (A2k)but at 135 kb it is still to big (any suggestions). The code I'm using is:
This one works:
==============
Private Sub exprtSSVeg_Click()
On Error GoTo exprtSSVeg_Err
DoCmd.Echo False, "The Application is Running. Be Patient!"
DoCmd.OpenQuery "qryGISExprtSSVeg", acNormal, acEdit
DoCmd.ApplyFilter "", "[qryGISExprtSSVEG]![DSSV-Project#]=[Forms]![Data Survey History]![DSH-Project#]"
DoCmd.OutputTo acQuery, "", "MicrosoftExcel(*.xls)", "", True, ""
DoCmd.Close acQuery, "qryGISExprtSSVeg"
DoCmd.Echo True, ""
exprtSSVeg_Exit:
Exit Sub
exprtSSVeg_Err:
MsgBox Error$
Resume exprtSSVeg_Exit
End Sub
This one doesn't: The bold are is what Access is choking on. Error message reads:The Microsoft Jet database engine doesn't recognize '[Forms]![Data Survey History]![DSH-Project#]' as a valid field name or expression.
===================
Private Sub exprtCrsTab_Click()
On Error GoTo exprtCrsTab_Err
DoCmd.Echo False, "The Application is Running. Be Patient!"
DoCmd.OpenQuery "qryGISExprtCT2", acNormal, acEdit
DoCmd.ApplyFilter "", "[qryGISExprtCT2]![DSSV-Project#]=[Forms]![Data Survey History]![DSH-Project#]"
DoCmd.OutputTo acQuery, "", "MicrosoftExcel(*.xls)", "", True, ""
DoCmd.Close acQuery, "qryGISExprtCT2"
DoCmd.Echo True, ""
exprtCrsTab_Exit:
Exit Sub
exprtCrsTab_Err:
MsgBox Error$
Resume exprtCrsTab_Exit
End Sub
Any help is greatly appreciated.
Thanks......Steve