Link to home
Start Free TrialLog in
Avatar of sunshine737
sunshine737

asked on

runtime error - runtime error '-2147217904 (80040e10)' - no value give for one or more required parameteres

Hello

Im doing a vba program and i have placed a combobox and retreived data from the Access database. Now when the user selects a value from the combo box, i want to display some other data from the table. i have tried this but im getting a runtime error 'runtime error '-2147217904 (80040e10)' - no value give for one or more required parameteres' on this line - rs1.Open "SELECT Employees.FName FROM Employees WHERE (((Employees.EmployeeID)=[result]))", myConn1

----

Private Sub ComboBox1_Change()

Dim result As String

result = ComboBox1.Value
MsgBox result

Dim myConn1 As ADODB.Connection
Dim rs1 As ADODB.Recordset

Set myConn1 = New ADODB.Connection
myConn1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:Hello\db2.mdb;Persist Security Info=False;"
myConn1.Open
Set rs1 = New ADODB.Recordset
Set rs1.ActiveConnection = myConn


rs1.Open "SELECT Employees.FName FROM Employees WHERE (((Employees.EmployeeID)=[result]))", myConn1

MsgBox rs1(FName)

------------
could anyone help me solving this error

thanks
SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunshine737
sunshine737

ASKER

>>>rs1.Open "SELECT Employees.FName FROM Employees WHERE (((Employees.EmployeeID)='" & result & "'))", myConn1

when im using this its giving an error as data type mismatch in criteria expression

actually i think last quesry is right as i tried it in the access and after giving the number from combobox its getting the fname value..........
Just take out the single quotes

Sorry I didnt notice that it was an id field

rs1.Open "SELECT Employees.FName FROM Employees WHERE (((Employees.EmployeeID)=" & result & "))", myConn1
which single quotes ?????
I believe plg and I are both correct - your msgbox won't work without either of our modifications.
rs1.Open "SELECT Employees.FName FROM Employees WHERE (((Employees.EmployeeID)=" & result & "))", myConn1
    MsgBox rs1(FName)

i have done this and is giving me an error as runtime error '3265'
item cannot be found in the collection corresponding to the requested name or ordinal
ok i have got it , i put comments and its working
but how can i diplay this value in the text field
sorry i mean quotes

rs1.Open "SELECT Employees.FName FROM Employees WHERE (((Employees.EmployeeID)=" & result & "))", myConn1
    MsgBox rs1("FName")
   
can somebody tell me how to display the samething in the text field please ...........urgent

thanks
text1.text = rs1.Fields("FName").Value
even
text1.text = rs1("FName")