sql - Run-Time Error '91' VBA Access when Adding record to Table -
i have table want add records using below function. when code executes, throws run-time error '91'
i've searched forums can't work out. below code:
private sub cmdcreateloan_click() dim tempinstal integer dim tempdate date dim strsql string dim dbs database
on error goto 0
if me.loan_status = 10 msgbox "loan created", , "loan created" me.loan_status = 9 docmd.save docmd.openquery "que_addinstalment", acviewnormal tempinstal = me.no_instalments - 1 tempdate = dateadd("m", 1, me.first_payment_date) while tempinstal > 0 set dbs = currentdb dbs.execute " insert [tblinstalments] " _ & "(loan_id,instalment_date, total_instalment,capital_instalment,interest_instalment,next_balance) values " _ & "('loan_id','tempdate','instalment','capital_instalment','interest_instalment','next_balance');" dbs.close set dbs = nothing tempinstal = tempinstal - 1 tempdate = dateadd("m", 1, tempdate) loop docmd.close else msgbox "loan contract not printed. please print before proceeding", , "print loan contract" end if end sub
Comments
Post a Comment