Error 3191 Cannot Define Field Name More Than Once

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
 
G

George Nicholson

This is just a guess based on a fuzzy memory, so if you get a more
definitive answer, run with that:

I seem to recall that TransferSpreadsheet (the import wizard?) only looks at
the first x characters in a field name to determine uniqueness (not sure
what x is. more than 8. 12? 16?) I'm thinking you might be getting that
because the first x characters of some of your field names are identical and
that causes the command to fail.

Easy enough to test, I hope.

If you find this to be the problem, please repost and let me know what x is
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top