ADODB RunTime Error

psycoperl

Active Member
Joined
Oct 23, 2007
Messages
339
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
  3. Web
I am getting a Runtime Error '-2147217904 (80040e10)' No value given for one or more required parameters

It is highlighting the line that starts with CK.Open

I dont see where this is coming from and the calls are similar to othere I have writen without errors.

Any Clues?

Code:
Private Sub CheckSessionForTests(SessionID As String)
    If Not IsNull(SessionID) Then
        Dim CK As ADODB.Recordset
        Set CK = New ADODB.Recordset
        CK.ActiveConnection = CurrentProject.Connection
        CK.LockType = adLockReadOnly
        CK.CursorType = adOpenDynamic
        CK.Open "Select * from tblTestSessions Where tsTestSessionsID ='" & SessionID & "'"
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Have you checked to see if SessionID is getting passed a value correctly?

This will not work:

If Not IsNull(SessionID) Then

because a string variable is NEVER null. It would be

If SessionID <> vbNullString Then

contrary to its name, vbNullString isn't really a null but is an empty string. ( "" )
 
Upvote 0
SessionID: 130
isNull(SessionID): False
SessionID <> vbNullString: True


Have you checked to see if SessionID is getting passed a value correctly?

This will not work:

If Not IsNull(SessionID) Then

because a string variable is NEVER null. It would be

If SessionID <> vbNullString Then

contrary to its name, vbNullString isn't really a null but is an empty string. ( "" )
 
Upvote 0
So is the field tsTestSessionsID really text and not numeric? It would appear that the value of your string is numeric in nature (but of course is being passed as a string). If the field is not numeric then it would not use the quotes and I would pass it as a long integer instead. If it is really text then I don't see anything wrong with your line of code to open unless the table you are opening is really a query and it has other parameters defined in it.
 
Upvote 0
The tsTestSessionsID is an "AutoNumber" field in the table

When I call the CheckSessionForTests() I am using the command CheckSessionForTests(tsTestSessionsID) as I am checking if the value in that field on the form is actually stored in the database so that I can pull up supplemental information.

I have tried CK.Open "Select * from tblTestSessions Where tsTestSessionsID =" & SessionID with the same error message.
 
Upvote 0
Solved this error ... tsTestSessionsID should have been tsTestSessionID.

Thank you for your help :-)
 
Upvote 0

Forum statistics

Threads
1,224,541
Messages
6,179,418
Members
452,912
Latest member
alicemil

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