C
corkster
I am trying to export to excel using docmd transfer spreadsheet. I
want to export each employee to a different workbook dynamically.
Hence my understanding is forms!Formname!contol will do this.
This is an overly simplification of what I am doing (for my
understanding). I have received help earlier from this group on this
and have used the ideas provided to me from that posting.
When the code gets to the sqltxt=Select Where empl!employee name = &
Forms![Form3]![employee name] I get the following error "Syntax error
(missing operator) in query expression '[empl]![Employee Name] =
Forms![Form3]![employee name]"
Notes: Query 3 lists all employees
Query 1 I have the following sql SELECT empl.empid,
empl.[Employee name]
FROM empl
WHERE ((([Forms]![Form3]![Employee name])<>False));
empl is a table
I hope somenone can help. I use Access 2003
Dim sFile As String
Set Mrecs = CurrentDb.OpenRecordset("Query3") 'Query 3 lists all the
employees
If Mrecs.RecordCount > 0 Then
With Mrecs
..MoveFirst
Do While Not .EOF
sFile = "C:\somefolder\" & ![employee] & " " & Format(Date,
"mm-dd-yyyy") '& " " & Date Target path and file name
Forms![Form3]![employee name] = ![employee] 'put actual names here
'sqltxt = "Delete * From empltemp"
'DoCmd.RunSQL sqltxt
sqltxt = "Select * Where [empl]![employee name] = &
Forms![Form3]![employee name]"
DoCmd.RunSQL sqltxt
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"empl", sFile, True, "Export" & ![employee]
..MoveNext
Loop
..Close
End With
End If
want to export each employee to a different workbook dynamically.
Hence my understanding is forms!Formname!contol will do this.
This is an overly simplification of what I am doing (for my
understanding). I have received help earlier from this group on this
and have used the ideas provided to me from that posting.
When the code gets to the sqltxt=Select Where empl!employee name = &
Forms![Form3]![employee name] I get the following error "Syntax error
(missing operator) in query expression '[empl]![Employee Name] =
Forms![Form3]![employee name]"
Notes: Query 3 lists all employees
Query 1 I have the following sql SELECT empl.empid,
empl.[Employee name]
FROM empl
WHERE ((([Forms]![Form3]![Employee name])<>False));
empl is a table
I hope somenone can help. I use Access 2003
Dim sFile As String
Set Mrecs = CurrentDb.OpenRecordset("Query3") 'Query 3 lists all the
employees
If Mrecs.RecordCount > 0 Then
With Mrecs
..MoveFirst
Do While Not .EOF
sFile = "C:\somefolder\" & ![employee] & " " & Format(Date,
"mm-dd-yyyy") '& " " & Date Target path and file name
Forms![Form3]![employee name] = ![employee] 'put actual names here
'sqltxt = "Delete * From empltemp"
'DoCmd.RunSQL sqltxt
sqltxt = "Select * Where [empl]![employee name] = &
Forms![Form3]![employee name]"
DoCmd.RunSQL sqltxt
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"empl", sFile, True, "Export" & ![employee]
..MoveNext
Loop
..Close
End With
End If