Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

False Duplication Error 3022 1

Status
Not open for further replies.

Domino2

Technical User
Jun 8, 2008
475
0
0
GB
I am getting an error trying to put a record in a child table. 3022. I get the Parent records autonumber from a listbox selection of the parent record.

I try to put the parent ID1 (Autonumber) into the foreign key of the child table but it errors?

Dim rs As DAO.Recordset
Dim db As Database
Set db = CurrentDb()

Set rs = db.OpenRecordset("Contacts", dbOpenDynaset)

rs.AddNew
rs.Fields(0) = Val(Me.List7.Column(0))(foreign key in Child table
rs.Fields(2) = Trim(Me.TT1) ' First Name
rs.Fields(3) = Trim(Me.TT2) ' Last Name
rs.Fields(6) = Trim(Me.TT3) ' Job Title
rs.Fields(5) = Trim(Me.TT4) ' Business Phone
rs.Fields(8) = Trim(Me.TT5) ' Home Phone
rs.Fields(7) = Trim(Me.TT6) ' Mobile
rs.Fields(4) = Trim(Me.TT7) ' Email
rs.Fields(9) = Trim(Me.TT8) ' Fax
rs.Update

Appreciate any ideas. Using Access 2000 (clients) and have been plagued with "Error Accessing files, Network connection may have been lost" Yet all patches done, SP3 ETC. Driving me mad Thanks
 
Something must have got corrupted in my table, I deleted all records and now no error. Also set bound column on list7 to get parent ID. So as long as my other error does not come back, alls well. Thanks
 
How are ya Domino2 . . .

Just to be safe side ... you should also:
Code:
[blue]    Dim db As [purple][b]DAO.[/b][/purple]Database[/blue]


See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks very much, yes I will do that. Anything to avoid more problems Mr Gates builds in!!
 
Domino2 . . .

BTW ... is this a typo?
Code:
[blue]rs.Fields(0) = Val(Me.List7.Column(0))[red][b](foreign key in Child table[/b][/red]

    should be

rs.Fields(0) = Val(Me.List7.Column(0)) [green][b]'foreign key in Child table[/b][/green][/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks very much, yes an embarassing typo, sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top