DoCmd.GoToREcord error!

R

Robert Nusz @ DPS

I have a problem adding New Records to its appropriate table via Form/Subform
usage. My parent form Fr_CR_U edits/updates table TST_FR_CASE_RECORDS. My
subform (sbFr_Add_Case_Others) to allow view, edit & updates to table
TST_FR_CASE_OTHERS. User is prompted for identifying record to be
viewed/updated, and query is performed, record located, and the forms above
displays the appropriate records. Allows scrolling (forward and backward)
through all records associated to main table selected record.

Problem lies when I click on command button to add new record, same form(s)
reflect clear subform for adding additional secondary record as needed. It
accepts data input to this form ok, but when you attempt to save the new
added record, (in any form or fashion of save function) it fails with message
of

The object doesn't contain the Automation object "LAST_NAME".

This field "LAST_NAME" is a required field for the primary table, the
primary record exists, all I want to do is add to the secondary table, which
is linked via parent/child link to the tables.

The process is attemtpting to use the

DoCmd.GoToRecord , , acNewRec

but the process fails with message as above. When you finally exit the
program, and inspect the table, the record that you attempted to add has been
added to the table, but I still need to get rid of the error message. I'm
not sure if the record gets added correctly on the add function or if it gets
added as the form is finally closed.

Can anyone assist?

Thanks,

code for Add_New_Record is :

Private Sub Command74_Add_New_Record_Click()
On Error GoTo Err_Command74_Add_New_Record_Click

Me.CASE_NUM_YR_OTHER.DefaultValue = Nz(Me.OpenArgs, "")
Me.CASE_NUM_OTHER.DefaultValue = Nz(Me.OpenArgs, "")
MsgBox "Now in Add_New_Record"
DoCmd.GoToRecord , , acNewRec

Exit_Command74_Add_New_Record_Click:
Exit Sub

Err_Command74_Add_New_Record_Click:
MsgBox Err.Description
Resume Exit_Command74_Add_New_Record_Click

End Sub

code for "Before Insert is"

Private Sub Form_BeforeInsert(Cancel As Integer)

MsgBox "Now In BeforeInsert"

If Me.CASE_NUM_OTHER <> Me.unbtxt_PREV_CASE_NUM Then
Me.unbtxt_PREV_CASE_YR = Me.CASE_NUM_YR_OTHER
Me.unbtxt_PREV_CASE_NUM = Me.CASE_NUM_OTHER
Me.unbtxt_PREV_SEQ_NUM = Me.txt_SEQ_NUM
Me.unbtxt_PREV_VEHICLE_CDE = Me.txt_VEHICLE_CDE
Me.unbtxt_PREV_OTHER_CDE = Me.txt_OTHER_CDE
End If

With Me.Parent
If .NewRecord Then
Cancel = True
MsgBox "You Must Enter The Case Record First"
Else
Me.txt_SEQ_NUM = (unbtxt_TtlRecNum + 2)
Me.CASE_NUM_YR_OTHER = Me.unbtxt_PREV_CASE_YR
Me.CASE_NUM_OTHER = Me.unbtxt_PREV_CASE_NUM
End If
End With

End Sub

code for "After update is"

Private Sub Form_AfterUpdate()

MsgBox "Now In Form_AfterUpdate"

Me.Refresh

Me.CASE_NUM_YR_OTHER = Me.unbtxt_PREV_CASE_YR
Me.CASE_NUM_OTHER = Me.unbtxt_PREV_CASE_NUM

End Sub

Other information can be supplied if needed.

Thanks in advance,
 

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