Using seperate form to add Record - docmd gotorecord acNewRec

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top