One To Many Relationship Follow

Legacy Poster

I want to have basically a header and multiple detail lines on a label. Has anyone created a script to read a detail file with multiple records that are associated to header information. The standard database setup lets me do this but for one only record from the detail file.

Here is what I have and it seems to go into loop. Make the program no respond

[b]Do While Field("ACKD1.order#") = Field("ACKH.order#")
Value = "ackd1.field"

Any help would be appreciated.


Fernando Ramos Miracle
Comment actions Permalink

If you wish to source information from the first record and maintained it fixed when printing the rest of records you will need to use an small VB Script with a counter (note that this is only one solution I though of, there might be others equally valid).

Basically you want (and please correct me if I'm wrong) to load the information from the first record on an embedded data object and maintain that information throughout the rest of printed records.

1. To get this done create your "header" with a shared name (in my case "header") and its data source type as "Embedded data" (screen data in older BarTender versions).

2. Create another data source (on the same object or on a different one, it's irrelevant) and set it as a Visual Basic Script type. Change the VB Script to an Event based VB Scripting and enter the following code:

[b]Functions and Subs:[/b]

'Declare the variable used as counter
[i]Dim var[/i]

[b]OnPrintStart event:[/b]

'Initial value of the variable so it gets the info from the first record.
[i]var = 0[/i]

[b]OnNewRecord event:[/b]

'If variable equals 0 (first record) then the data source "header" receives the information from the database field.
[i]If var = 0 Then
Format.NamedSubStrings("header").Value = Field("<databaseFieldName")
End If

var = var+1[/i]

This way the first, on the first record the information will be loaded on the "header" shared data source but it won't change the value of that object on the rest of records.

Please test it and let me know how it goes.

Please sign in to leave a comment.