Pull data from Access to Excel "Runtime Error-2147217904(80040e10)"

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
776
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

I am trying to pull a record from an Access table into excel to use but I get an error "No value given for one or more required parameters" and I am unsure how to fix the error.
The "mysearch1" when the code runs and picks up the correct reference to find but unsure where to go from here. The only thing I can think of is that the "UNIQUEREF" isnt in the correct format.


Code:
Sub FindRef()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim mysqlst, mysearch1 As String

mysearch1 = ThisWorkbook.Sheets("Quality Assurance Marking").Range("Q10").Value

    mysqlst = "SELECT BusinessLineTest.RACF,  " & _
   "BusinessLineTest.CallId, " & _
   "BusinessLineTest.Q1 FROM BusinessLineTest WHERE (BusinessLineTest.UniqueRef= " & mysearch1 & ") ;"

Set cn = New ADODB.Connection
With cn
.ConnectionString = con1
.Open
End With

Set rs = New ADODB.Recordset
rs.Open mysqlst, cn, adOpenDynamic, adLockPessimistic
   ThisWorkbook.Sheets("Current Marked").Range("B2").CopyFromRecordset rs
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

thanks in advance
Gavin
 
Assuming it's text, it should be in single quotes:

Code:
WHERE (BusinessLineTest.UniqueRef= '" & mysearch1 & "');"
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top