ccondran08
Registered User.
- Local time
- Tomorrow, 06:44
- Joined
- Feb 27, 2014
- Messages
- 58
Hi, looking for some help here please. I have a form that has a textbox in what I've called the "settings" tab of a control tab. The user can click on a button and edit the text box and type in an Activity Code that is then saved and used in a query to retrieve records that the user has selected (eg. [Forms]![frm_Main_Menu]![txtActivity1]).
The code below is used to export the query and paste it into a spreadsheet that is located in the directory of "TRACpath". During the execution of the code I get an Run-time error "3061" which appears and then the VBA editor appears and is highlighted on the following line ;
Set rs_Milestones = qdf_Milestones.OpenRecordset()
Can anyone please shed some light on this so I can get this finished...:banghead:
Dim XL As Excel.Application
Dim xlWB As Workbook
Dim wbTarget As Workbook
Dim TRACpath As String
TRACpath = [Forms]![frm_Main_Menu].[txtTRAC_Path]
Dim qdf_Milestones As QueryDef
Dim rs_Milestones As Recordset
Set qdf_Milestones = CurrentDb.QueryDefs("qry_P3_Milestone_Gaps")
Set rs_Milestones = qdf_Milestones.OpenRecordset()
Set XL = CreateObject("Excel.Application")
Set wbTarget = XL.Workbooks.Open(TRACpath)
wbTarget.Worksheets("Data").Cells(2, 186).CopyFromRecordset rs_Milestones
wbTarget.Save
wbTarget.Close
Set wbTarget = Nothing
Set XL = Nothing
Set qdf_Milestones = Nothing
The code below is used to export the query and paste it into a spreadsheet that is located in the directory of "TRACpath". During the execution of the code I get an Run-time error "3061" which appears and then the VBA editor appears and is highlighted on the following line ;
Set rs_Milestones = qdf_Milestones.OpenRecordset()
Can anyone please shed some light on this so I can get this finished...:banghead:
Dim XL As Excel.Application
Dim xlWB As Workbook
Dim wbTarget As Workbook
Dim TRACpath As String
TRACpath = [Forms]![frm_Main_Menu].[txtTRAC_Path]
Dim qdf_Milestones As QueryDef
Dim rs_Milestones As Recordset
Set qdf_Milestones = CurrentDb.QueryDefs("qry_P3_Milestone_Gaps")
Set rs_Milestones = qdf_Milestones.OpenRecordset()
Set XL = CreateObject("Excel.Application")
Set wbTarget = XL.Workbooks.Open(TRACpath)
wbTarget.Worksheets("Data").Cells(2, 186).CopyFromRecordset rs_Milestones
wbTarget.Save
wbTarget.Close
Set wbTarget = Nothing
Set XL = Nothing
Set qdf_Milestones = Nothing