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:

  1. add new record on form1
  2. click button on form1 open form2
  3. when form2 opens, contains info form1

i have process similar in database , things way.

  1. the users have form enter new records
  2. 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.
  3. 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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -