473,378 Members | 1,207 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

.AddNew does not work if a relationship is declared.

The following code copies recordset rs into recordet rst and adds it
to tblVMSParts. The records being copied are the data that shows on a
subform. I copy all of the data from the main record, create a new
record, paste it all in with a new key and then create the subform
records with the new key ([VMS]). This works perfectly if I have no
relationship declared between the parent table and the child table.
As soon as I set up the relationship the subform records no longer get
copied over. Stepping through the code it seems to work but the new
records are not created.

I am completely stumped.

rs.MoveFirst
Do Until rs.EOF
With rst
.AddNew
![VMS] = strVMS
![Quantity] = rs![Quantity]
![Description] = rs![Description]
![PartNum] = rs![PartNum]
![Torque] = rs![Torque]
.Update
End With
rs.MoveNext
Loop

rs.Close
Set rst = Nothing

rst.Close
Set rst = Nothing

Thanks,

Bill
Newtown, PA
Nov 12 '05 #1
2 1709
Bill,
are you including the Foreign key in your child table? If not,
referential integrity constraints are disallowing your add.
Essentially, what this means is, if you do not add a Foreign Key value
that is in the domain of foreign key (in your parent table), then the
insert will ALWAYS fail. So you have to add something like:

rs.Fields("ForeignKeyFieldName")= ...' some legal value

and then you should be fine.

HTH,
Pieter
Nov 12 '05 #2
Thanks for the reply. In my code you can see

With rst
.AddNew
![VMS] = strVMS

![VMS]is the foreign key from the child. The 5 fields I am updating are
the only 5 fields in the table. I was wrong in my first posting, this
works when I have the relationship defined but does not work when I turn
on referential integrity.
Thanks,

Bill
Newtown, PA

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: cv | last post by:
Hello All, I have used MultipartRequest like the following to upload images. MultipartRequest multi = new MultipartRequest(request, "../webapps/coreprogram/dealerlogos", 1024 * 1024); It...
4
by: Field | last post by:
Hi, the following snippet shows once executed this output: 2 2 I'd have rather expected this output: 2 10
2
by: Tim Marshall | last post by:
ODBC situation, Access 97, here is the code and I've marked where Access coughs up. The Access error message is 3027, can't update, database is read only. The Oracle table in question has a...
4
by: Das | last post by:
Hi, I have made an application in ASP.net with C#. The application works fine with localhost. I have uploaded the site. I'm using web user controls in the form. but some of the button do not work...
2
by: Tom | last post by:
I'm getting this error when I try to pass a structure to a dll. An unhandled exception of type 'System.ArgumentException' occured in Test1.exe Additional Information: Type could not be marshaled...
10
by: powelly | last post by:
Hi i Know this looks weird by i done a database in 2000 all worked well than i had to convert it to 97. I had to redo all my code that was fine but i can not get the form to addnew when OnOpen runs...
3
by: powelly | last post by:
Can someone help with this I would like to have a form open at a new record. I have done this in access 2000 with Private Sub Form_Open(Cancel As Integer) Recordset.AddNew End Sub and no...
1
by: Newbie in ChiTown | last post by:
Here's my code: I am using MS Access and I am trying to update a table (InvoiceDetails) with data input by the user on a form. However, it does not update nor does it give me an error message. ...
11
by: Jim | last post by:
Hi, I want to schedule a Python program that reads the command line for input. However, when adding an argument to the command line Python will not pick it up when using Windows scheduled...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.