ms access - Running a database in run time version brings up an error -
i've finished creating database , works on computer. i'm using access 2013 , in vba code have written error handler each function/sub use in databases. users designed have access run-time 2007 , every time run on machine un-trapped error "execution of application has stopped due run-time error".
code command button.
option compare database
private sub command0_click() dim errorstep string docmd.setwarnings false '------------------------------------------------------------------------------------- ' procedure : command0_click ' author : chris sparkes ' date : 13/08/2013 '------------------------------------------------------------------------------------- errorstep = "1 - cleansing records" docmd.openquery "qry1_3" docmd.openquery "qry4-7" docmd.openquery "qry9" call exceloutputreport exit_command0_click: on error goto 0 exit sub command0_click_error: msgbox "error in procedure command0_click of vba document." goto exit_command0_click on error goto 0 end sub public function exceloutputreport() dim errorstep string docmd.setwarnings false '--------------------------------------------------------------------------------------- ' procedure : exceloutputreport ' author : chris sparkes ' date : 13/08/2013 '--------------------------------------------------------------------------------------- errorstep = "1 - cleansing records" dim dblocal dao.database dim tbloutput dao.recordset 'dao declarations dim objexcel new excel.application dim objworkbook excel.workbook dim objworksheet excel.worksheet dim intcurrtask integer dim blurb string set dblocal = currentdb() set tbloutput = dblocal.openrecordset("tbl_output") set objexcel = createobject("excel.application") set objworkbook = objexcel.workbooks.open("g:\enliven sales report\envliven_report_template_1.xls") set objworksheet = objworkbook.worksheets("enliven") objexcel.visible = true objworkbook.windows(1).visible = true tbloutput.movefirst intcurrtask = 2 while not tbloutput.eof objworksheet .cells(intcurrtask, 1).value = tbloutput![customerordercode] .cells(intcurrtask, 2).value = tbloutput![customercode] .cells(intcurrtask, 3).value = tbloutput![customerdescription] .cells(intcurrtask, 4).value = tbloutput![itemcode] .cells(intcurrtask, 5).value = tbloutput![itemdescription] .cells(intcurrtask, 6).value = tbloutput![dateorderplaced] .cells(intcurrtask, 7).value = tbloutput![customerduedate] .cells(intcurrtask, 8).value = tbloutput![quantity] .cells(intcurrtask, 9).value = tbloutput![shippedquantity] end intcurrtask = intcurrtask + 1 tbloutput.movenext loop tbloutput.close dblocal.close docmd.setwarnings true set tbloutput = nothing set dblocal = nothing set objworksheet = nothing set objworkbook = nothing set objexcel = nothing exit_exceloutputreport: on error goto 0 exit function exceloutputreport_error: msgbox "error @ in procedure exceloutputreport of vba document." goto exit_exceloutputreport end function
has got ideas may causing this? references should fine i'm using same ones know have worked different databases i've made.
thanks, chris
you have added error routines, did not activate them. @ beginning of methods, add on error goto
statement:
private sub command0_click() on error goto command0_click_error ... end sub public function exceloutputreport() on error goto exceloutputreport_error ... end sub
in error routines, should display (at least) contents of err.description
instead of generic error message. otherwise, have hard time tracking source of errors. e.g.:
msgbox "error in procedure command0_click: " & err.description
Comments
Post a Comment