K
KHogwood-Thompson
I have the following code in a function:
Function cmdExport()
Dim dbD As DAO.Database
Dim rsJOBREF As DAO.Recordset
Dim strFilespec As String
Dim lngJOBREF As String
Dim strSheet As String
Dim strSQL As String
Const SQL1 = "SELECT * INTO [Excel 8.0;HDR=Yes;Database="
Const SQL2 = "FROM CVR WHERE JOBNO = "
Set dbD = CurrentDb()
Set rsJOBREF = dbD.OpenRecordset("SELECT JOBNO FROM CVR GROUP BY JOBNO" _
, dbOpenSnapshot)
strFilespec = "G:\MSData\Kevin Hogwood\Pollards\CVR\New Data.xls"
Do Until rsJOBREF.EOF
'Get JOBREF
lngJOBREF = rsJOBREF.Fields("JOBNO").Value
strSheet = CStr(lngJOBREF)
'Assemble the SQL query to export one jobref
strSQL = SQL1 & strFilespec & ";].[" & strSheet & "] " _
& SQL2 & "'" & lngJOBREF & "'" & ";"
'export it
dbD.Execute strSQL, dbFailOnError
rsJOBREF.MoveNext
Loop
rsJOBREF.Close
End Function
I have a macro that has the RunCode action and the following as the function
name:
cmdExport ()
When I try to run this macro I get the following error:
The express yoo#u entered has a function name that Microsoft Access can't
find.
Does anyone know why this is happening?
Function cmdExport()
Dim dbD As DAO.Database
Dim rsJOBREF As DAO.Recordset
Dim strFilespec As String
Dim lngJOBREF As String
Dim strSheet As String
Dim strSQL As String
Const SQL1 = "SELECT * INTO [Excel 8.0;HDR=Yes;Database="
Const SQL2 = "FROM CVR WHERE JOBNO = "
Set dbD = CurrentDb()
Set rsJOBREF = dbD.OpenRecordset("SELECT JOBNO FROM CVR GROUP BY JOBNO" _
, dbOpenSnapshot)
strFilespec = "G:\MSData\Kevin Hogwood\Pollards\CVR\New Data.xls"
Do Until rsJOBREF.EOF
'Get JOBREF
lngJOBREF = rsJOBREF.Fields("JOBNO").Value
strSheet = CStr(lngJOBREF)
'Assemble the SQL query to export one jobref
strSQL = SQL1 & strFilespec & ";].[" & strSheet & "] " _
& SQL2 & "'" & lngJOBREF & "'" & ";"
'export it
dbD.Execute strSQL, dbFailOnError
rsJOBREF.MoveNext
Loop
rsJOBREF.Close
End Function
I have a macro that has the RunCode action and the following as the function
name:
cmdExport ()
When I try to run this macro I get the following error:
The express yoo#u entered has a function name that Microsoft Access can't
find.
Does anyone know why this is happening?