473,498 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Duplicate subforms content and key link to another master table key

Hi,

Here is the following scenario.

I do have a master table with related subforms from wich I need to
create a revision.
But I need to duplicate the content of the subforms and link them to
the new entry in the master table.

Each string possess its unique identifier number.

So in this case I have a master table with the following structure
(simplified)

DesiID = Design Unique Identifier
Pnum = Project number
PPro = Prototype Number
PRev = Revision Number
FieldN = other fields

And subforms attached to the master table by the Unique identifier

PartID = Part Unique Identifier
DesiID = Link to master table
FieldN = Other Fields

Both strings are attached ONLY by the DesiID
I have the code (see code snippet) that allow me to create the
duplicate I need but it keeps attaching it to the original DesiID
instead of the new freshly created one by the revision generator.
I am scr(..) with this because all new entries remains attached to the
original DesiID instead of the new one... Thats my problem !

This is where I need a hand !

Thanks

CODE
================================================== ==========================
With Me.RecordsetClone
.AddNew
'
!PRev = Nz(DMax("PRev", "Design", "[PNum]=" & Me.PNum
& " And [PPro]= " & Me.PPro), 0) + 1
!ProjID = Me.ProjID
!PNum = Me.PNum
!PPro = Me.PPro

.Update

Dim strSQL As String
strSQL = "insert into Design_Struct (DesiID, FieldN) Select DesiID,
FieldN FROM Design_Struct WHERE Design_Struct.DesiID = " & Me.DesiID &
""
CurrentDb.Execute strSQL

Me.Bookmark = .LastModified
Me.Requery: Me.Refresh

End With
Jun 27 '08 #1
1 1678
On May 12, 10:06 pm, SirTKC <andre.artsyst...@gmail.comwrote:
Hi,

Here is the following scenario.

I do have a master table with related subforms from wich I need to
create a revision.
But I need to duplicate the content of the subforms and link them to
the new entry in the master table.

Each string possess its unique identifier number.

So in this case I have a master table with the following structure
(simplified)

DesiID = Design Unique Identifier
Pnum = Project number
PPro = Prototype Number
PRev = Revision Number
FieldN = other fields

And subforms attached to the master table by the Unique identifier

PartID = Part Unique Identifier
DesiID = Link to master table
FieldN = Other Fields

Both strings are attached ONLY by the DesiID

I have the code (see code snippet) that allow me to create the
duplicate I need but it keeps attaching it to the original DesiID
instead of the new freshly created one by the revision generator.
I am scr(..) with this because all new entries remains attached to the
original DesiID instead of the new one... Thats my problem !

This is where I need a hand !

Thanks

CODE
================================================== ==========================
With Me.RecordsetClone
.AddNew
'
!PRev = Nz(DMax("PRev", "Design", "[PNum]=" & Me.PNum
& " And [PPro]= " & Me.PPro), 0) + 1
!ProjID = Me.ProjID
!PNum = Me.PNum
!PPro = Me.PPro

.Update

Dim strSQL As String
strSQL = "insert into Design_Struct (DesiID, FieldN) Select DesiID,
FieldN FROM Design_Struct WHERE Design_Struct.DesiID = " & Me.DesiID &
""
CurrentDb.Execute strSQL

Me.Bookmark = .LastModified
Me.Requery: Me.Refresh

End With
If I am understanding you correctly, your .Addnew....Update code adds
a new record to the master table, and your SQL adds a new record to
the related table. To make this work you're either going to have to
set the form's current record to your newly created record between
the .Update and the strSQL or you're going to have to save the value
of your newly created DesiID to insert into your SQL, e.g.
Dim lngDesiID as Long

With Me.RecordsetClone
.AddNew
'
!PRev = Nz(DMax("PRev", "Design", "[PNum]=" & Me.PNum
& " And [PPro]= " & Me.PPro), 0) + 1
!ProjID = Me.ProjID
!PNum = Me.PNum
!PPro = Me.PPro
lngDesiID = !DesiID ' save value of new autogenerated
DesiID
.Update

Dim strSQL As String
strSQL = "insert into Design_Struct (DesiID, FieldN) Select DesiID,
FieldN FROM Design_Struct WHERE Design_Struct.DesiID = " & lngDesiID &
""
Jun 27 '08 #2

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

Similar topics

4
1884
by: Jeremiah J. Burton | last post by:
I am trying to create a database (in Acces 2000) to track my fossil collection. I have a main table that has records for every specemen. I have a secondary table with information on localities...
3
3397
by: radioman | last post by:
Hi all, I would appreciate some help please. I just need pointing in the right direction as I am at a loss. Basically I have a form (frmAddMaster) which displays two subforms "Master Stock...
1
2971
by: M Wells | last post by:
Hi All, I am developing an Access 2003 project application with the back end in SQL Server 2003. I have a master form that tracks projects, and several subforms on it that track various...
3
3831
by: Diana Gard | last post by:
Perhaps this is a design flaw, please let me know. I'm using Access 2000. I have a form with a tab control and 5 subforms within those tabs. The forms match with the tables: Client main,...
9
9513
by: Zeeshan Iqbal via AccessMonster.com | last post by:
hi, im trying to design a form with two subforms. subforms no.1 (orders) is connected to the main form by customer ID and i dont know how i can connect another subform (order details)to the first...
2
3089
by: Terry | last post by:
Hello, I wonder if anyone can shed light on this problem for me. I have an Access 97 front end with an SQL 2000 database. There is a Business main form with an Owner subform and corresponding...
2
8372
by: darnel | last post by:
I have 4 hierarchical tables and want to display it all together as a form and 3 subforms, when subform displays (and allow to add/edit) only relevant items from each superior subform. Tables are:...
3
2575
by: 6afraidbecause789 | last post by:
Think school - students - discipline interventions - misbehaviors - staff for this one....On a mainform frmStudentInterventions, I have linked a subform (sfrmMisbehaviors) with another subform...
7
1825
by: jaad | last post by:
While at it I have another one that has been bugging me to no extent: I have a work order form, this work order form has a subform called Work order details, there is another form attach to that...
0
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6881
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.