Form not linking when adding a new record

  • Thread starter ielmrani via AccessMonster.com
  • Start date
I

ielmrani via AccessMonster.com

Hi,
I have a subform (subform1) with several records. Each record in subform1
has a button next it. When I click on the button it show another form (form2)
that contains the clients info. it works fine but the problem I am having is
when I create a new record.
When I add a new record to the subform1 (I add just first name and last name)
and then I click on the button that opens form2 (I add address, phone etc).
I am able to add these info but when I exit form2 the data is no longer there
for the new record. I know the reason but I can't find a solution.
The preason is this: The link between these 2 forms is Autonumber. when I
create a new record in subform1 it creates an autonumber, and the same thing
in form2. Except form2's autonumber is alwyas 1 more than subform1. and
that's why the data is not linked.
How do I solve this
I hope this is not confusing. I also did some search in this forum but no
luck. Thanks
Here is the code behind form2:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form2"

stLinkCriteria = "Autonumber=" & [AutoNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Thanks in advance
 
G

Golfinray

I would probably never link subform and mainform on an autonumber unless it
was a one-to-one relationship (like one owner, one house.) If nothing else,
go back and create something like an ID number that is tied to both.
 
I

ielmrani via AccessMonster.com

We'll do. thank you
I would probably never link subform and mainform on an autonumber unless it
was a one-to-one relationship (like one owner, one house.) If nothing else,
go back and create something like an ID number that is tied to both.
Hi,
I have a subform (subform1) with several records. Each record in subform1
[quoted text clipped - 23 lines]
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