Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Forms _ Copy First Record Down On Subform

Posted by: ollyhutsy Nov 8 2019, 03:59 AM

I am currently trying to create a button which will copy the first line of a grn number into the remaining records in a subform. This is because items which are received are normally booked in at the same time, but not always. I am wanting to be able to click a button to copy the grn record in the first line down for the remaining records.

Private Sub CopyDown()
With Me.[supptrn subform3].Form.RecordsetClone
If Not (.BOF And .EOF) Then .MoveFirst
While Not .EOF
.Edit
![GRN] = ![GRN]
.Update
.MoveNext
Wend
End With
End Sub

Posted by: ollyhutsy Nov 8 2019, 05:16 AM

Solved using the following code for anyone with a similar issue

Dim A As String
Dim B As String
Dim C As String
A = [supptrn subform3]![GRN]
B = [supptrn subform3]![Booked In By]
C = [supptrn subform3]![Date In]
With Me.[supptrn subform3].Form.RecordsetClone
If Not (.BOF And .EOF) Then .MoveFirst
While Not .EOF
.Edit
![GRN] = A
![Booked In By] = B
![Date In] = C
.Update
.MoveNext
Wend
End With

Posted by: Jeff B. Nov 8 2019, 09:06 AM

I'm not sure I understand your description. It sounds like you're saying you want to have (some of) the same data stored in a 'parent' record also stored in any related 'child' records. If so, reconsider your design. In a well-normalized relational database, you would NOT want to do that. Instead, the primary key of the parent record would be stored, as a 'foreign key' in each related child record, pointing back to the parent that "owns" the child record.