Dupe values/Saving record.

C

Chris

I am unable to save a new record after having saved a new record. Yes, that
is correct. With a clean start I can enter a new reservation. Then if I try
for a second reservation all my data is accepted but I cannot close my forms
to complete the entry procedure.

The code below is called from [1frmClient]. My intent is to add a new
reservation, which is made up of and invoice form and a visits form.

Code in event to add new reservation:
DoCmd.OpenForm "2frmReservation", , , , acFormAdd
DoCmd.GoToRecord , , acNewRec
Forms![2frmReservation]![Invoicefrm].Form!InvNum = DMax("InvNum", "tbl 2
Job") + 1
Forms![2frmReservation]![VisitsBCfrm].Form!txtInvNum =
Forms![2frmReservation]![Invoicefrm].Form!InvNum

[2frmReservation] is a parent to two subforms: [Invoicefrm] and
[VisitsBCfrm].

[2frmReservation] and [Invoicefrm] control source = [qry2Reservation].
[VisitsBCfrm] control source = [tbl2ReservationBC] (this query includes
[tbl2Reservation]).
[InvNum] control is on all three of the above forms.

All subform names have been checked and the Parent/Child link for each is
[InvNum]

[InvNum] is the primary key in [tbl2Reservation] and [tbl2ReservationBC];
the tables are related with enforced RI cascading Update/Delete.


The user, while on [1frmClient] selects to add a new reservation. The
[2frmReservation] form opens with the focus on [Invoicefrm]. When the user
has completed [Invoicefrm] the focus is set to [VisitsBCfrm] for its
completion. Then I send the user back to [Invoicefrm] for review.

I am then unable to close [2frmReservation] due to duplicate values message.

These forms and this code works fine for updating the records as the records
already exist, but not with adding a record. I am certain that my issue is
timing of saving the record.

Also, when adding new reservation the [InvNum] controls are fine (empty),
but the [VisitsBCfrm] controls contain the values of the previous failed
record. Checking the tables all records are there but it appears my problem
is closing/saving or something of the sort.

MVP/Experts: help me please.
 

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

Similar Threads

setting focus to 3rd subform 20
syntax error 3075 11
Run-time error '3075' 10
Dynamic Naming of Form Button 3
Split form 0
Subform goes blank 1
Subform button not getting correct record 4
Launch Email Template 1

Top