ms access - SQL - Save record with listbox and textbox change -


i have list box - user clicks 1 of results in list box that's populated table.

when click 1 of items in list box text boxes populate results in table

on textbox have on change code of:

docmd.runsql "update tbl_complaintscoded set [ticketnumber] = '" & text3 & "' id = " & list1.column(0) 

text3 shows ticket number text5 shows department

its department user trying change before getting error of:

data type mismatch in criteria expression

thanks help

just fun, rewrote put in little more elegant basic error handling , little more streamlined.

option compare database 'added option explicit verify variables option explicit  private sub button_click() 'error handling on error goto button_click_err_handler  dim rs dao.recordset  'is ticketnumber column text data type?  me.list1.column(0) should return variant value, assuming     'your ticketnumber column of number type name implies, think use: 'set rs = currentdb.openrecordset("select * tbl_name ticketnumber = " & me.list1.column(0))  set rs = currentdb.openrecordset("select * tbl_name ticketnumber = '" & me.list1.column(0) & "'")  'you should check bof , eof if you're checking if there no record. if rs.bof , rs.eof     msgbox "you have not selected record, nothing save!", vbinformation     'exiting here, instead of wrapping entire sub in if...  ...end if statement.  use "exit sub", added     'the exit , error handling make little more graceful.     goto button_click_exit end if  'i wrapped rs edits in statement , used direct column name operator ! instead of collection searching rs() feature. 'for illustration, wrapped few of references in nz() function.  if none of fields ever null, bravo excellent 'database design , database users discipline, have couple columns nulls allowed. rs     .edit      'top categories     !business = me.text5     !status = me.text8     !maildate = me.text10      'complaint detail section     !type = me.text19     !sub = me.text21     !c = me.text23      'complaint coding section     !touch2 = me.combo29     !touch1 = me.combo33     !cause2 = me.combo31     !cause1 = me.combo35      'cs account details section     !account = me.text39     !feed = me.combo41      'logged audit user     !loggeduser = me.text43     !datetimelogged = me.text49      .update end  'exit procedure button_click_exit: on error resume next exit sub  'error handling button_click_err_handler: msgbox err.number & err.description, vbokonly + vbcritical, "error" resume button_click_exit  end sub 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -