Normal Topic Report with only one record of the subform (Read 465 times)
etejeira
Junior Member
**
Offline


No personal text

Posts: 60
Joined: Aug 6th, 2005
Report with only one record of the subform
Feb 9th, 2006 at 11:46pm
Print Post Print Post  
I have a database with a subform and I want to design a report which includes various records of the main form and for each one I want to include only the latest record of the subform.
Up to now I have been making reports which give me all the records of the subform related to each of the records of the main form that I select.
Now I want just the last one of the subform records for each of the main form records.
Is that possible?
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Report with only one record of the subform
Reply #1 - Feb 10th, 2006 at 1:56pm
Print Post Print Post  
This can be done with a little programming in the subform report.

Place this in the Global Code of the subform report:
Code
Select All
Var vTimes as Int = 2
Var vCnt as Int = 1 


Place this in the first Group Body event:
Code
Select All
If vCnt <= vTimes Then
     {
     vCnt = vCnt + 1
     Visibility(HDate,1)
     Visibility(Cost,1)
     Visibility(SH,1)
     Visibility(From,1)
     Visibility(Note,1)
     }
Else
     {
     Visibility(HDate,0)
     Visibility(Cost,0)
     Visibility(SH,0)
     Visibility(From,0)
     Visibility(Note,0)
     } 


Of course, you will need to exchange my LE names for yours. You will want one Visibility function for each Group Body column that you have.

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Report with only one record of the subform
Reply #2 - Feb 10th, 2006 at 4:16pm
Print Post Print Post  
Don't have access to correct syntax right now, but try these two variations.  Both are based on getting FormResultSetTotal() of records

1.  Use RecordSetTotalCount in @ FormFieldValue using FormResultSetTotal for the "instance" value

2.  Use FormResultSetTotal to go to Record Position using FormResultSetTotal for the position value

Code
Select All
var vRecord as Int
var vLastRecord as String

vRecord = @FormResultSetTotal(FormName!SubForm)

//Example 1 --- gets a field value from a specific record number
vLastRecord = @FormFieldValue(frmName!subForm,Field, vRecord)

//Example 2 --- Moves you to specific record to get access to all fields for that record.
RecordSetCurrentPosition(vRecord) 



==================
As cautioned above, syntax may be incorrect.  But depending on what you want to do with the last record, one or both of these may help you.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged