I see a few things that should be fixed.
You have "Dim rst As DAO.Recordset", but then use "rs"
Code:
Dim rst As DAO.Recordset
<snip>
<snip>
Set rs = db.OpenRecordset("create excel time sheets for selected employees on main menu")
With rs
.MoveFirst
Do While Not .EOF
fn = rs.Fields("First Name")
<snip>
You probably don't have "Option Explicit" as the 2nd line in your module because you have a lot of undeclared variables: sdt, edt, fn, Ln, ns, ne, bc, t, rs (as noted above)
Shouldn't use spaces, punctuation or special characters (except the underscore) in object names.
I am surprised that you don't get an error using a comma in a file name. Underscores would be better than commas.
Code:
gg = "C:\aaa\timesheets\EmployeeTimeReport_for_" & fn & "_" & Ln & "_" & sdt & "_to_" & edt & ".xls"
The code could be re-written to eliminate the Goto:
Code:
<snip>
t = Len(Dir(gg))
If t = 0 Then
GoTo keepgoing1
Else
t = MsgBox("File already exists, Delete file and continue ?.", vbYesNo, "")
If t = vbYes Then
Kill gg
Else
Exit Sub
End If
End If
keepgoing1:
On Error Resume Next
Me.barcode = bc
<snip>
Code:
<snip>
t = Len(Dir(gg))
If t <> 0 Then
t = MsgBox("File already exists, Delete file and continue ?.", vbYesNo, "")
If t = vbYes Then
Kill gg
Else
Exit Sub
End If
End If
On Error Resume Next
Me.barcode = bc
<snip>
Have you looked at Ken Snell's site at http://www.accessmvp.com/kdsnell/EXCEL_Export.htm
Lots of examples of writing to Excel sheets......