opening forms in add mode, one control's data automatically entere

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

another newcomer/new user to the group. i have a main form, frmMain, from which i have several command buttons which serve to open up another form, frmDocumentation. I designed the database with the intention that each button would open up the same form (frmDocumentation) but enter a different string for one of the controls. This might not be a problem, but i also need to link frmDocumentation to frmMain, which i'm doing using a link criteria string... so i have frmMain with a primary key "SID#" which links to a foreign key "SID#" in frmDocumentation, but i also want to automatically enter data into another control, "Section", and this data is different for every command button. Further, i need frmDocumentation to open up in Add mode each time.

This doesn't seem like it should be hard, but i continue to get error messages. i think it's probably more of a design than a code issue... but if there are any thoughts or suggestions, i would REALLY appreciate it.

thanks.
 
Erinu,

There seems to be a contradiction in your description. If you are
opening the frmDocumentation form in Add mode, then you can't use a link
criteria, because a link criteria can only apply to existing records.
If I correctly imagine what you are doing, you possibly need to
specifically assign the value of the SID to the new record. So your
code might be something like this...
DoCmd.OpenForm "frmDocumentation, , , , acFormAdd
With Forms!frmDocumentation
!SID = Me.SID
!Section = "YourText"
End With

On a completely side issue, it is not a good idea to use a # as part of
the name of a field or control.
 
Back
Top