S
Sam
I am usign the following code and it was working great. I've changed/
added tables and now I get the error message 3191 Cannot Define Field
Name more then once. I can not figure out why. Please Help.
Thanks
Sub ExportQueriesSam()
On Error GoTo Err_Handler
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strQueryName As String
Set db = CurrentDb
For Each qdf In db.QueryDefs
strQueryName = qdf.Name
If strQueryName Like "MASUNL*" Then
SysCmd acSysCmdSetStatus, "Exporting " & strQueryName &
"..."
DoCmd.TransferSpreadsheet _
acExport, _
acSpreadsheetTypeExcel9, _
strQueryName, _
"C:\My Documents\MASUNL\" & strQueryName & ".xls",
True
End If
Next qdf
DoCmd.Hourglass False
MsgBox "Done. Please move files to the Appropriate Transfer
Folder!"
Exit_Point:
DoCmd.Hourglass False
SysCmd acSysCmdClearStatus
Set db = Nothing
Exit Sub
Err_Handler:
DoCmd.Hourglass False
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
GoTo Exit_Point
End Sub
added tables and now I get the error message 3191 Cannot Define Field
Name more then once. I can not figure out why. Please Help.
Thanks
Sub ExportQueriesSam()
On Error GoTo Err_Handler
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strQueryName As String
Set db = CurrentDb
For Each qdf In db.QueryDefs
strQueryName = qdf.Name
If strQueryName Like "MASUNL*" Then
SysCmd acSysCmdSetStatus, "Exporting " & strQueryName &
"..."
DoCmd.TransferSpreadsheet _
acExport, _
acSpreadsheetTypeExcel9, _
strQueryName, _
"C:\My Documents\MASUNL\" & strQueryName & ".xls",
True
End If
Next qdf
DoCmd.Hourglass False
MsgBox "Done. Please move files to the Appropriate Transfer
Folder!"
Exit_Point:
DoCmd.Hourglass False
SysCmd acSysCmdClearStatus
Set db = Nothing
Exit Sub
Err_Handler:
DoCmd.Hourglass False
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
GoTo Exit_Point
End Sub