terry beckman said:
Current status has changed. I was able to use the following code to
insert a new record and create the estimate number. Now I just need
to retrieve and display it on the form.
Current code is:
DoCmd.GoToRecord , , acNewRec
Me![e_part_ID] = "'!'"
Me!estimate_date = FormatDateTime(Now(), vbShortDate)
stSQL = "Insert into dbo.estimate (e_part_ID, estimate_date,
e_m_cert)" & _
" Values (" & [e_part_ID] & "," & [estimate_date] & "," & 0 &
")" DoCmd.RunSQL stSQL, no
'DoCmd.GoToRecord , , acPrevious
'DoCmd.GoToRecord , , acNext
cboPart.SetFocus
The GotoRecord still receives the 2105 error - can not go to this
record. Please help in displaying the record with the estimate
number. Part ID is a combo box to select a part number.
What GoToRecord? You don't show an active GoToRecord call except the
one that goes to the new record at the top of the code. Is that the one
that is failing, or is it one that you are executing somewhere else,
possibly as part of the AfterUpdate code for cboPartNumber.
Your logic seems flawed to me. I'm assuming that the form is based on
dbo.estimate. You are dirtying a record on the form, then adding that
record via an append query. That will make it impossible to save the
form's record, and the form will not know about the record you added via
the append query. You'll need to requery both the form and combo box if
you want them to know about the record you added with the append query.
Did you ever try my suggestion of using RunCommand acCmdSaveRecord? Did
simple code like this work or not?
RunCommand acCmdRecordsGoToNew
Me![e_part_ID] = "'!'"
Me!estimate_date = FormatDateTime(Now(), vbShortDate)
Me!e_m_cert = 0
RunCommand acCmdSaveRecord
???
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)