Problem carrying a value from the previous record to a new record

A

Amit

Access 2K, Windows XP
=====================
I have a form (frmA) with a control "ProgramID" in it.
Using a button, I open another form (frmB) to
View/Edit/AddNew Objectives for the "ProgramID". frmB has
2 controls on it - a comboBox for ProgramID, and a textBox
for Objective. The code in frmA, OnClick event:
__________________________________________________________

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmB"
stLinkCriteria = "[ProgramID]=" & Me![ProgramID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
__________________________________________________________

This opens frmB displaying the existing Objectives for the
ProgramID in frmA.

The desired functionality for frmB is that when I click on
the navigation button (while on an existing record) to add
a new record, I would like the ProgramID to be the same as
the one in the existing record.

I have the following code in the AfterUpdate event of the
comboBox used to select the ProgramID:
__________________________________________________________

Me.cboNOProgramID.DefaultValue = Me.cboNOProgramID
__________________________________________________________

This works fine (that is, the value of ProgramID is
carried to the new record) when I
- add a new record and select the ProgramID,
- go to a second new record

but it doesn't work if I go to a new record from an
existing record.

My guess is that I need to put the above code in some
other event, either for the comboBox, or the form. But,
I'm not sure which event is triggered when I go from an
existing record to a new record.

Any help will be appreciated.

Thanks!

-Amit
 

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