ms access - Prefill a field on another form with command button -


i have access 2003 database handling rma (return material auth) information (date, rma nbr, evaluation, ship date, items on rma, etc). in access database have 3 forms:

  • add rma (adds new rma database no items. form (will have) subform on listing items on rma added far)
  • view rma (views information on existing rma's in database, items on each rma in subform)
  • add item rma (since each rma can have more 1 different type of item being returned, have form dedicated adding new item rmas. after each entry, form clears , allows more entries)

the 'add rma' , 'add item' rma forms have unbound fields (they're designed accept new input , insert database when button pushed.

the 'add item rma' form has 5 fields, unbound. actual form not referencing information database @ all. 1 of 5 fields rma number.

the 'new rma' , 'view rma' forms have button supposed open 'add item rma' form. said button open 'add item rma' form rma number field pre-filled rma number previous screen. each field on each form has name "rmanbr".

on command button in 'view rma' form have the following code in "on click" event not seem working. 'add rma item" field shows blank:

private sub additemtorma_click()   docmd.openform "add item rma", , , "rmanbr = " & me!rmanbr end sub 

keep in mind fields unbound.

so, need code automatically fill in unbound rmanbr field on 'add item rma' form rmanbr field 'add rma' , 'view rma' forms.

i have subforms in 'add rma' , 'view rma' listing items refresh/requery after each item added through 'add item rma' form (when button pushed). i've tried

rma inforation.requery add rma.requery 

with no success. no refresh, no errors, nothing.

can done code?

not sure how followed description, seems might take advantage of openargs parameter openform. (your existing code uses wherecondition parameter, meaningless unbound form.)

openargs seventh parameter openform. if counted commas correctly, work:

docmd.openform "add item rma", , , , , , me!rmanbr 

however, use option's name avoid counting commas.

docmd.openform "add item rma", openargs:=me!rmanbr 

then in target form's load event, can move new record , use openargs value in text box holds rmanbr (i guessed text box name txtrmanbr).

private sub form_load()     docmd.gotorecord acdataform, , acnewrec     if not isnull(me.openargs)         me.txtrmanbr = me.openargs     end if end sub 

Comments