sql - Searching a table to find a certain ID: error 80040e10 no value for one or more parameters -


in access 2007, searching table find id. id address given in text box user idtxt.
error 80040e10 no value 1 or more parameters.

private sub search_click()   'here new part i'm not sure about... dim cn adodb.connection dim rsq adodb.recordset  set cn = currentproject.connection set rsq = new adodb.recordset  dim strsql string  dim id_number integer dim blnexists boolean blnexists = false id_number = idtxt.value  strsql = "select * table1  id = id_number;" rsq.open strsql, cn, adopenstatic  if rsq.recordcount <> 0      ' found     blnexists = true     msgbox "found" else     msgbox "not found" end if  end sub 

your passing string without substituting value;

strsql = "select * table1  id = id_number;" 

needs

strsql = "select * table1  id = " & id_number 

as id_number in context of vba variable outside string.

(your not performing type checking on id_number text in unrestricted textbox error, , string parameters injection vulnerability)

also note recordcount can return -1 depending on cursor location/type.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -