ms access - open from from newly entered record before save -
in access 2007. enter new record on form. click button has macro action open form. can make form open linked new record? understand need primary key on new form etc. if record saved can make second form open data. question when it's still new record/form need navigate directly onto linked form...
please share direction on this..
if understanding question need following:
- add new record on form1
- click button on form1 open form2
- when form2 opens, contains info form1
i have process similar in database , things way.
- the users have form enter new records
- they use button click post new data table. during process, return primary key new record. final process of button click, tell open new form, , populate primary key grabbed.
- new form opens using pk record.
my code button click in vba:
private sub ok_click() dim rst dao.recordset dim rst1 dao.recordset dim sqlstr string dim rptid variant set rst = currentdb.openrecordset("tble_investigations", dbopendynaset, dbseechanges) ' here need add each of fields form rst.addnew rst![table.column1] = me![formfield1] rst![table.column2] = me![formfield2] rst![table.column3] = me![formfield3] rst.update ' sql string return new id of record added sqlstr = "select max([id]) [maxofid] tble_investigations;" set rst1 = currentdb.openrecordset(sqlstr, dbopendynaset, dbseechanges) rst1.movefirst rptid = rst1![maxofid] 'here open form2 new id. docmd.openform "frm_details", acnormal, , "[id]= " & rptid, acformedit, acwindownormal docmd.close acform, "frm_new", acsaveyes end sub
edit:
based on telling sounds doing following:
private sub ok_click() dim rst dao.recordset dim rst1 dao.recordset dim sqlstr string dim rptid variant set rst = currentdb.openrecordset("t_evaluation", dbopendynaset, dbseechanges) ' here need add each of fields form rst.addnew rst![executionleadorg] = me![executionleadorg] 'the field form matches table column rst![titleid] = me![titleid] rst![t_evaluation.evaltypeid] = me![t_evaluation.evaltypeid] rst![sectionid] = me![sectionid] rst![lobevaluation] = me![lobevaluation] 'you need continue doing each field on form rst.update ' sql string return new id of record added sqlstr = "select max([evaluationid]) [maxofid] t_evaluation;" set rst1 = currentdb.openrecordset(sqlstr, dbopendynaset, dbseechanges) rst1.movefirst rptid = rst1![maxofid] 'here open form2 new id. docmd.openform "f_lobevalpopupentry", acnormal, , "[evaluationid]= " & rptid, acformedit, acwindownormal docmd.close acform, "f_evalnew", acsaveyes end sub
Comments
Post a Comment