New Record

  • Thread starter Thread starter Gator
  • Start date Start date
G

Gator

I have a form/subform. I have an event that opens a popup. I select from a
list on the popup that copies the value onto a txtbox on the Main form and
the popup then automatically closes. In the same code I place the focus in
the subform to begin adding data to a new record. The problem I 'm having is
that when the focus is set in the sub, there are two lines. The top line,
which is the one I'm entering data in, does not automatically put the
autonumber in for the ID that links the tables, but the record below it does,
which is one that I'm not using. When I fill in the data for the record that
the autonumber is not filled and try to goto a new record I get some error
saying that I can't add or change a record because there needs to be a
related record in the related table. This seems to be a fundamental problem
but I don't know how to approach it.
 
Hi Gator,

You didn't say whether the form/sub-form corresponds to a table and a
related table. If it does, then your popup should programmatically create a
new record in the related table using the ID of the main table. The ID you
can read while on the popup. Once you created the new record in the related
table (using the ID as the foreign key), simply requery the sub-form before
moving the focus to the form.

It could be that the two records you see in the sub-form are due to the
Allow Data Entry or Additions set to TRUE.

I hope the above helps...
Cheers
Michael
 
Back
Top