473,379 Members | 1,185 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,379 software developers and data experts.

Trying to copy a parent/child record combination and encountering code failure

Okay, I have records that some underlying data is the same, but in some subforms, you might have variable input that uniquely ID's each stock item.

I've gotten the coding to copy both the parent and child records with no problems, but I'm running into continual issue with part of the parent recordset.

My table is tblStockHeader --- relevent fields are Item_Type, UoM, Sport, Card_Year, Brand, Card_Number and Subset. All are text fields as Card_Year could be 99/00 and Card_Number often contain lettering. I get runtime 2465 Error when I click on my command Copy Button that says that Access can't find the 'Card_Number' referred to in the expression. I have verified multiple times the spelling is correct in both and since the other fields copy over properly, I don't believe it's the underlying tbl issue.

DISREGARD: Turns out my form I was copying from was using a different query to pull together some different information. Once I verified that Card_Number was part of the rowsource for that, it resolved itself.


Expand|Select|Wrap|Line Numbers
  1. Dim db As Database
  2. Dim recBusiness As DAO.Recordset
  3. Dim recPlayerFrom As DAO.Recordset
  4. Dim recPlayerTo As DAO.Recordset
  5. Dim recStkAttrFrom As DAO.Recordset
  6. Dim recStkAttrTo As DAO.Recordset
  7. Dim lngBusinessKey As Long
  8.  
  9. Set db = CurrentDb
  10.  
  11. If Not IsNull(Me.Stock_ID) Then
  12.  
  13.     Set recBusiness = db.OpenRecordset("tblStockHeader", dbOpenDynaset)
  14.  
  15.     'copy the parent record and remember its key
  16.     recBusiness.AddNew
  17.     recBusiness!Item_Type = Me!Item_Type
  18.     recBusiness!UoM = Me!UoM
  19.     recBusiness!Sport = Me!Sport
  20.     recBusiness!Card_Year = Me!Card_Year
  21.     recBusiness!Brand = Me!Brand
  22.     recBusiness!Card_Number = Me!Card_Number
  23.     recBusiness!Subset = Me!Subset
  24.     recBusiness.Update
  25.     recBusiness.Bookmark = recBusiness.LastModified
  26.     lngBusinessKey = recBusiness!Stock_ID
  27.  
  28.     recBusiness.Close
  29.     Set recBusiness = Nothing
Oct 13 '10 #1
1 1734
ADezii
8,834 Expert 8TB
Try a change in Syntax, specifically Line# 11:
Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Me.Stock_ID) Then
  2.   Set recBusiness = db.OpenRecordset("tblStockHeader", dbOpenDynaset)
  3.     With recBusiness
  4.       'copy the parent record and remember its key
  5.       .AddNew
  6.          !Item_Type = Me!Item_Type
  7.          !UoM = Me!UoM
  8.          !Sport = Me!Sport
  9.          !Card_Year = Me!Card_Year
  10.          !Brand = Me!Brand
  11.          !Card_Number = Me![Card_Number]
  12.          !Subset = Me!Subset
  13.       .Update
  14.          .Bookmark = .LastModified
  15.          lngBusinessKey = !Stock_ID
  16.     End With
  17.  
  18.     recBusiness.Close
  19.     Set recBusiness = Nothing
  20. End If
Oct 13 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mark Tait | last post by:
Hi - I think I'm getting very tied up here. Using Web Matrix, and have posted in the asp.net forum, with no help unfortunately. I have a table, which has a parent/child relationship with itself....
4
by: news.online.no | last post by:
In a query, I need too be able to show if a parent record has a child record. Using the query in a combo box too select record in a form. Thanks :)
1
by: Kevin Myers | last post by:
Hello, I have a form that contains several sub-forms corresponding to tables which are conceptually children of the main table for the form. On this form, I need to have a button that allows...
4
by: Danny Tuppeny | last post by:
Hi all, I've been trying to write some classes, so when I have a parent-child relationship, such as with Folders in my application, I don't have to remember to add a parent reference, as well as...
3
by: PAUL | last post by:
Hello, I have 2 datasets I am trying to update. The parent table seems to update fine but when I go update the chiled table I get an error message that says I need a related record in the parent...
0
by: sandi | last post by:
I have Parent child table as decribe below: Parent Table name = TESTPARENT 1. counter bigint isIdentity=Yes Increment=1 Seed=1 2. customer nChar(10) Child Table name = TESTCHILD...
0
by: khoegen | last post by:
Folks, I am in the process of designing a database, within which I have created a table called "tblDOCUMENTS". As the title suggests, this is a list of documents (records) of varying types. I...
1
by: Hexman | last post by:
Hello All, What I'm trying to do is update a child record using a parent-child relation. I want to find out if it is faster than than doing multiple selects. Anyways, I've created a dataset...
8
by: Rick | last post by:
VS 2005 I' m setting up a parent/child datagridviews in a form. I am doing a lot of this by hand coding in order to get the feel of things. I want a change in the parent table to trigger a...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...

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.