Changes requested would create duplicate values in the index....

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with two subforms. It has two primary fields. fgnOriginatorID
and StartDateID. The form and subforms seem to work well together except
when I try to add a new record. The main form generates thru code a new
StartDateID that is a week after the previous record and the fgnOriginatorID
is passed to the new record. The originator can be changed at that point if
someone else is writing the document.

One subform is linked by only the date. The other is linked to both primary
fields.

When the new record is generated, the date and name show up and then I get
the error message in the subject line if any control is accessed.
The table for the main form does not seem to be getting the data. If I go
to the table and put in manually only the two primary fields, the form opens
correctly with the new date and originator. Then I have code that adds other
information which works correctly.
Any ideas would be appreciated. I'm sure it's something simple I'm
overlooking but can't find.
 
It seems like you have the field from the wrong table in your query.
I don't know your table structure, but lets say Table1 has the Primary ID
StartDateID and Table2 has the FgnOriginatorID. If you want to fill table1
with item from table2, you must have a fgnOridinatorID field on table1, but
just as a number field, not autonumber and it should be a long interger.
When you link the tables in a query by that field, the FgnOriginatorID field
from table1 must be in the query, not the autonumber field from table2.
Anne
 
Thanks for your reply. I'm trying to go thru my query now. I made copies
and am trying variations. I don't think the subforms are the issue now
because I deleted them from one copy and got the same error when a new record
was added.
The table for my main form uses the StartDateID and fgnOriginatorID as the
primary keys. The fgnOriginatorID is linked to a separate table where
tOriginatorID is the primary key and then name and title information is
stored. I was trying to avoid another field in the table for a primary key
because the date and name create a unique identifier. I may try putting that
in the table and see what happens. Also, I originally only had the date as
the primary key and was getting the error then too.
This is the sub that I use to start the new record. I use variations of
this for other forms and don't have the same problem.

Private Sub addnew_Click()
On Error GoTo Err_addnew_Click
Dim ENGR As String
FLAG = True <- used to exit FORM_CURRENT before any code
is executed there
SD = fSTDate
ENGR = fOriginatorID
DoCmd.GoToRecord , , acNewRec <create new record
FLAG = False
fSTDate = SD + 7
fOriginatorID = ENGR
Form_Current

I trace the code and it all seems to be working to put in other information
into unbound textboxes in Form_Current. The form that is generated looks ok
but just doesn't work.
 
Back
Top