UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> two similar operations for a single report detail    
 
   
archeomason
post Dec 15 2004, 12:03 AM
Post #1

UtterAccess Enthusiast
Posts: 76
From: Austin, TX, USA



I recently requested help in compiling a series of records into a single field with a comma separating the records and was directed to a tutorial website which has pretty much helped out... Here's the link: http://support.microsoft.com/default.aspx?...uct=acc2000#kb2
The general code is as follows:

Sub grpHeaderCategoryID_Format (Cancel As Integer, FormatCount As Integer)

Me!AllProducts = Null
FirstPass = False

End Sub

Followed by:

Sub Detail_Format (Cancel As Integer, FormatCount As Integer)
On Local Error GoTo Detail_Format_Err
If Not FirstPass Then
Me!AllProducts = Me![ProductName]
FirstPass = True
Else
Me!AllProducts = Me!AllProducts & ", " & Me![ProductName]
End If
Detail_Format_End:
Exit Sub
Detail_Format_Err:
MsgBox Error$
Resume Detail_Format_End
End Sub

That has worked great... (with some modifications specific to my db of course...)
I am, however, still stuck... I would like this sub to do a series of three similar operations to produce three separate comma-delineated fields for a single report. I'm sure that this is a basic coding, but how do I essentially run the above operation for one comma-delineated field, then do the same for another source field and destination field on the same report, then repeat that for another source and destination?

Since the tutorial has tied the sub to the ONFormat Event, I'm fairly sure that this all has to be coded in one long string, but am not well-versed enough in the coding to get it to run. I can run it for one field only, more than one and I'm stuck...

Any help would really, really, really be appreciated...
Go to the top of the page
 
+
strive4peace
post Dec 17 2004, 08:40 PM
Post #2

UtterAccess VIP
Posts: 20,228
From: Colorado



in the future, when you post code, please use

CODE
above your codeblock and


below your codeblock.

This makes it easier for others to read and, therefore, help you
Go to the top of the page
 
+
strive4peace
post Dec 17 2004, 08:42 PM
Post #3

UtterAccess VIP
Posts: 20,228
From: Colorado



I simplified things a little by assigning an empty string to the control instead of null -- this makes the FirstPass variable unnecessary

CODE
Sub grpHeaderCategoryID_Format(Cancel As Integer, FormatCount As Integer)

   Me.AllProducts = ""
   Me.AllOther1 = ""
   Me.AllOther2 = ""

End Sub

'------------------ Followed by:

Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
   On Local Error GoTo Detail_Format_Err

   If Not IsNull(Me![ProductName]) Then
      Me.AllProducts = Me.AllProducts & ", " & Me![ProductName]
   End If

   If Not IsNull(Me![Other1]) Then
      Me.AllOther1 = Me.AllOther1 & ", " & Me![Other1]
   End If

   If Not IsNull(Me![Other2]) Then
      Me.AllOther2 = Me.AllOther2 & ", " & Me![Other2]
   End If
  
Detail_Format_End:
   Exit Sub

Detail_Format_Err:
   MsgBox Err.Description, , "ERROR " & Err.Number & "  Detail_Format"
   Resume Detail_Format_End

End Sub
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 20th June 2013 - 06:54 AM