I have a compile error... method or data member not found.
I get this error on ALL the commands I click. In the past I have had no problem with these, been running just fine. Until now.
When I click I get the error and .RANGE is highlighted. This happens on all of the commands I have, all of them.
When I comment out that line, it then sticks, same error on the, !FullNameCPt
I thought it was the excel file, so I made a TESTONE and tried that, same error.
I'm not sure what happened.
Thanks
Dennis
I get this error on ALL the commands I click. In the past I have had no problem with these, been running just fine. Until now.
When I click I get the error and .RANGE is highlighted. This happens on all of the commands I have, all of them.
When I comment out that line, it then sticks, same error on the, !FullNameCPt
I thought it was the excel file, so I made a TESTONE and tried that, same error.
I'm not sure what happened.
Thanks
Dennis
Code:
Private Sub CmdOpen1203Insp_Click()
On Error GoTo SubError
Dim xlApp As Excel.Application
Dim xlWkb As Excel.Workbook
Dim xlWks As Excel.Worksheet
Dim SQLCpt As String
Dim SQLLt As String
Dim SQLYearCur As String
Dim rsCpt As DAO.Recordset
Dim rsLt As DAO.Recordset
Dim rsYearCur As DAO.Recordset
SQLCpt = " SELECT TblMembers.LastName, TblMembers.FirstName, TblMembers.Position, 'Captain' & "" "" & [FirstName] & "" "" & [LastName] AS FullNameCpt " & _
" FROM TblMembers " & _
" WHERE TblMembers.Position='Capt [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=3]#3[/URL] ' "
SQLLt = " SELECT TblMembers.LastName, TblMembers.FirstName, TblMembers.Position, 'Lieutenant' & "" "" & [FirstName] & "" "" & [LastName] AS FullNameLt " & _
" FROM TblMembers " & _
" WHERE TblMembers.Position='Lt [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=3]#3[/URL] ' "
SQLYearCur = " SELECT 'October' & "" "" & Format(Now(),'yyyy') AS YearCur " & _
"FROM TblMembers "
Set rsCpt = CurrentDb.OpenRecordset(SQLCpt, dbOpenSnapshot)
Set rsLt = CurrentDb.OpenRecordset(SQLLt, dbOpenSnapshot)
Set rsYearCur = CurrentDb.OpenRecordset(SQLYearCur, dbOpenSnapshot)
Set xlApp = New Excel.Application
'Set xlWkb = xlApp.Workbooks.Open(CurrentProject.Path & "\Master\Trk_Insp_1203.xlsx")
Set xlWkb = xlApp.Workbooks.Open(CurrentProject.Path & "\Master\TESTONE.xlsx")
Set xlWks = xlWkb.Sheets("Oct")
xlApp.Visible = True
With xlWks
'[COLOR=#ff0000].Range([/COLOR]"B6").NumberFormat = "mmmm yyyy"
'.Range("B6").Value = (rsYearCur!YearCur)
.Range("B9").Value = (rsCp[COLOR=#0000ff]t!FullNameCpt)[/COLOR]
.Range("T9").Value = (rsLt!FullNameLt)
End With
SubExit:
On Error Resume Next