Hello All -
Ultimate Goal = Exporting Query results to Excel
Problem = Run-Time Error '-2147217904 (80040e10)' No value given for one or more required paramters
The error occurs on red highlighted line in code below
I know the problem is referencing my form control value as the parameter in SQL via VBA. Any ideas?
Thanks in adavnce!
Ultimate Goal = Exporting Query results to Excel
Problem = Run-Time Error '-2147217904 (80040e10)' No value given for one or more required paramters
The error occurs on red highlighted line in code below
I know the problem is referencing my form control value as the parameter in SQL via VBA. Any ideas?
Code:
Private Sub Command3_Click()
' Access Dims and Sets
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim MyRecordset As New ADODB.Recordset
MyRecordset.ActiveConnection = cnn
Dim cmd As New ADODB.Command
Set cmd.ActiveConnection = CurrentProject.Connection
Dim MySQL As String
' Excel Dims
Dim MySheetPath As String
Dim Xl As Excel.Application
Dim XlBook As Excel.Workbook
Dim XlSheet As Excel.Worksheet
MySQL = "SELECT [CO-DIV].* FROM [CO-DIV] WHERE ((([CO-DIV].SHIPTO) Like [Forms]![frm_Queries].[FirstFive] & '*')) Or ((([CO-DIV].POINTER) Like [Forms]![frm_Queries].[FirstFive] & '*')) Or ((([CO-DIV].PRICE) Like [Forms]![frm_Queries].[FirstFive] & '*')) ORDER BY [CO-DIV].SHIPTO;"
[B][COLOR=darkred]MyRecordset.Open MySQL[/COLOR][/B]
MySheetPath = "C:\'Whatever'.xlsm"
Xl.Visible = True
XlBook.Windows(1).Visible = True
Set XlSheet = XlBook.Worksheets("Profiles")
XlSheet.Range("a1").CopyFromRecordset MyRecordset
MyRecordset.Close
Set cnn = Nothing
Set Xl = Nothing
Set XlSheet = Nothing
Set XlBook = Nothing
Thanks in adavnce!