Using seperate form to add Record - docmd gotorecord acNewRec

G

Guest

I am trying to open a form to add a record to a table. I am in a main form
that contains an "Application Number" called AppNum. I need AppNum to flow
over to the new form that is opening into a FORM field called Appnum. My Sub
routine is not working. Can anyone help. Thanks,

Private Sub Add_Memo()
On Error GoTo Err_Command148_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Post_Closing_Data_update_memos_Form"

stLinkCriteria = "[AppNum]=" & Me![Post_closing_data.AppNum]
DoCmd.OpenForm stDocName, acNormal, , acFormAdd
DoCmd.GoToRecord , , acNewRec
[Forms]![Post_Closing_Data_update_memos_Form]![AppNum] = stLinkCriteria
 
G

Guest

There is no need to open a form to add a record to a table in fact that's not
how it is normally done.
You can create SQL to do an INSERT directly to the table.

Your code wont work because after opening the form, control passes to the
event handlers of the just opened form, it does not continue in sequence to
your statement below. There is a a way to make it do that, but that's not
what you want.

-Dorian
 

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