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.
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.
Code:
Dim db As Database
Dim recBusiness As DAO.Recordset
Dim recPlayerFrom As DAO.Recordset
Dim recPlayerTo As DAO.Recordset
Dim recStkAttrFrom As DAO.Recordset
Dim recStkAttrTo As DAO.Recordset
Dim lngBusinessKey As Long
Set db = CurrentDb
If Not IsNull(Me.Stock_ID) Then
Set recBusiness = db.OpenRecordset("tblStockHeader", dbOpenDynaset)
'copy the parent record and remember its key
recBusiness.AddNew
recBusiness!Item_Type = Me!Item_Type
recBusiness!UoM = Me!UoM
recBusiness!Sport = Me!Sport
recBusiness!Card_Year = Me!Card_Year
recBusiness!Brand = Me!Brand
recBusiness!Card_Number = Me!Card_Number
recBusiness!Subset = Me!Subset
recBusiness.Update
recBusiness.Bookmark = recBusiness.LastModified
lngBusinessKey = recBusiness!Stock_ID
recBusiness.Close
Set recBusiness = Nothing
Comment