How to open a new form & auto-populate Record ID with ID from Original Form?

  • Thread starter Pamela via AccessMonster.com
  • Start date
P

Pamela via AccessMonster.com

Hello;

I have a problem with one of my forms. What I am trying to do is the
following:

I have a subform on a main form (sfrmTaskAudit) with a button on it which,
when clicked opens another form, frmTerm. The two tables the forms are based
on, tblTaskAudit & tblTerm, are related via there RecID fields. What I am
trying to do is to get the RecID field on the form, frmTerm, to be auto-
populated with the RecID from the calling form. It does do this if there is
an existing record in the tblTerm table, but if there is not, the user has to
manually enter the record ID in the RecID field. Is there a way to get it to
populate with the same recID present on the calling form? I seemed to have
it working before but it is not working now.


Here is the code I have currently:


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmTerm"

stLinkCriteria = "[TermID]=" & Me![RecID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

I'm using Access 2002

Thanks!

-Pamela
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top