BREAK BY With multiple joins in Progress ABL - progress-4gl

I am trying to learn Progress ABL and I can not find a good example of using break by with multiple joins. The error I am getting right now is Colon followed by white space terminates a statement. (199).
The last time I ran into this error it was because I didn't have my end statement in the correct place, but I don't know if that is it or not. Any help is appreciated.
DEFINE QUERY q1
FOR platte.item FIELDS (item item_ptr costing_uom stocking_uom size description default_uom_conv_factor),
platte.item_branch FIELDS (weight_uom load_uom weight load_factor),
platte.item_uomconv FIELDS (system_id item_ptr_sysid),
platte.uom_conv FIELDS (convert_from convert_to conv_factor),
platte.product_group_minor FIELDS (major minor).
OPEN QUERY q1
FOR EACH item WHERE (item.system_id = '000000') NO-LOCK,
EACH item_branch WHERE (item_branch.system_id = item.system_id
AND item_branch.item_ptr = item.item_ptr) NO-LOCK,
EACH item_uomconv WHERE (item_uomconv.system_id = item.system_id
AND item_uomconv.item_ptr_sysid = item.system_id
AND item_uomconv.item_ptr = item.item_ptr) NO-LOCK,
EACH uom_conv WHERE (uom_conv.system_id = item_uomconv.uom_ptr_sysid
AND uom_conv.uom_ptr = item_uomconv.uom_ptr) NO-LOCK,
EACH product_group_minor WHERE (product_group_minor.system_id = item.pg_ptr_sysid
AND product_group_minor.pg_ptr = item.pg_ptr) NO-LOCK BREAK BY item.item:
DISPLAY
item.item LABEL "item" "|SEP|"
item.item_ptr LABEL "item_ptr" "|SEP|"
item.size LABEL "size" "|SEP|"
item.description LABEL "description" "|SEP|"
WITH WIDTH 250.
END.

Your construct is incorrect - the last "END" statement doesn't belong, unless you change the OPEN QUERY for a FOR EACH .....like so:
FOR EACH item
WHERE (item.system_id = '000000')
NO-LOCK,
EACH item_branch
WHERE (item_branch.system_id = item.system_id AND
item_branch.item_ptr = item.item_ptr)
NO-LOCK,
EACH item_uomconv
WHERE (item_uomconv.system_id = item.system_id AND
item_uomconv.item_ptr_sysid = item.system_id AND
item_uomconv.item_ptr = item.item_ptr)
NO-LOCK,
EACH uom_conv
WHERE (uom_conv.system_id = item_uomconv.uom_ptr_sysid AND
uom_conv.uom_ptr = item_uomconv.uom_ptr)
NO-LOCK,
EACH product_group_minor
WHERE (product_group_minor.system_id = item.pg_ptr_sysid AND
product_group_minor.pg_ptr = item.pg_ptr)
NO-LOCK
BREAK BY item.item:
DISPLAY
item.item LABEL "item"
"|SEP|" VIEW-AS TEXT
item.item_ptr LABEL "item_ptr"
"|SEP|" VIEW-AS TEXT
item.size LABEL "size"
"|SEP|" VIEW-AS TEXT
item.description LABEL "description"
"|SEP|" VIEW-AS TEXT
WITH WIDTH 250
DOWN
.
END.

I have taken the liberty of simplifying the example to use the well-known "sports2000" database. To have a dynamic query that uses BREAK-BY and joins your code should be more like this:
define query q1 for customer, order scrolling.
open query q1 for each customer no-lock, each order no-lock of customer break by order.shipDate.
get first q1.
do while available customer:
display customer.name order.shipDate.
get next q1.
end.
1) To use BREAK-BY in a dynamic query you need that query defined as SCROLLING.
2) The OPEN QUERY statement should end with a ".", not a ":".
3) You have to actually fetch the data prior to displaying it. GET FIRST and GET NEXT do that in my example.

Long time since I've done any progress, but I'd be tempted to remove the terminal colon on this line
AND product_group_minor.pg_ptr = item.pg_ptr) NO-LOCK BREAK BY item.item:

Related

How to amend the below code to replace the "text" searched, in this case "london" for text in a particular cell, "Registration Form" Sheet Cell C15

Below is the code I am using to find text within a data table and return all rows that contain that text on another sheet. The code works on a full data table with now empty cells, however I want to perform the same task but instead of giving the text to search within the code, I want this to be determined by the user in a given cell on the sheet.
Sub CopyOverBudgetRecords()
Dim StatusCol As Range
Dim Status As Range
Dim PasteCell As Range
Set StatusCol = Sheets("Data Sheet").Range("c8:l35")
For Each Status In StatusCol
If Sheets("Registration Form").Range("c22") = "" Then
Set PasteCell = Sheets("Registration Form").Range("c22")
Else
End If
If Status = "london" Then Range(Status.End(xlToLeft), Status.End(xlToRight)).Copy PasteCell
Next Status
End Sub
I tried
using - If Status = "london" Then Range(Status.End(xlToLeft), Status.End(xlToRight)).Copy PasteCell
Replacing "london" With Sheets ("Registration Form").Range("c15").value
So - If Status = Sheets ("Registration Form").Range("c15").value Then Range(Status.End(xlToLeft), Status.End(xlToRight)).Copy PasteCell. This didn't work.

Suppress a Text Object Based on Field Value in Object

I have a Text Object that contains a text string followed by a database field Max Weight {table.field}
I want to suppress all of the Text Object whenever {table.field} = 0.
I tried the following formula under Format Text > Common > Suppress
if {table.field} = 0 then true else false
What I get is the field value within the text object either on or off while the text is always suppressed. What do I need to do to make this work? Thanks.
You can try 2 different solutions:
1) Keeping your Max Weight label, create a new Formula in the 'Formula Fields' then enter this code:
if {table.field} = 0 then '' else ToText({table.field})
2) Supressing all text, you have to create a new Formula too, but type this:
if {table.field} = 0 then '' else 'Max Weight ' + ToText({table.field})
This second way, you will create a label that will only appears when your conditions happens, and you must replace the old TextObject with this new Formula. This will cause a blank area, because no text and no weight will show, but it looks like exactly what you need.
I just tested here and it's working. Note that both 'spaces' are in the document. Attached is an image that may help you find the formulas section. Hope you can use it.

Access VBA to Change an Image in a Continuous Form

I am trying to create a receipt form where people will confirm if they've received the full quantity of an order. As part of this, I want the following to happen:
If they received the full quantity, a green check mark appears
If they received a partial quantity, an orange triangle appears
If they received no items, a red x appears
To accomplish this, I'm using a continuous form with 3 image files for each situation. I'm using the code below to change the image when the quantity is changed. The problem is, when the quantity is change on 1 line, the symbol changes for all lines. I'll post pictures as well.
Any thoughts on how I can fix this?
I'm open to other methods of accomplishing this idea too.
Private Sub FinalQTY_AfterUpdate()
If IsNull(Me.FinalQty) Then
MsgBox "You must enter a quantity for this item"
Me.FinalQty.SetFocus
Exit Sub
Else
LValue = Me.[FinalQty]
If IsNumeric(LValue) = 0 Then
Me.FinalQty = ""
MsgBox "Qty must be a numeric value"
Me.QTY.SetFocus
Exit Sub
End If
End If
Me.FinalTotalPrice = Me.FinalPrice * Me.FinalQty
If Me.FinalQty = 0 Then
Me.Yes.Visible = False
Me.Change.Visible = False
Me.No.Visible = True
End If
If Me.FinalQty < Me.QTY Then
Me.Yes.Visible = False
Me.Change.Visible = True
Me.No.Visible = False
End If
If Me.FinalQty = Me.QTY Then
Me.Yes.Visible = True
Me.Change.Visible = False
Me.No.Visible = False
End If
End Sub
This is before I adjust the quantity:
This is after I adjust the qty of only the second line:
Since the formatting of each record displayed by a continuous form is inherited from the form design template, any changes to the template will be automatically applied to all records displayed by the form, aside from Conditional Formatting rules in effect or the handful of properties which may changed via the OnPaint event of the Detail section.
One possible alternative might be to add a new field to your table with a data type of OLE Object and populate the value on the AfterUpdate event using the AppendChunk method, sourcing image data from a separate table containing three records corresponding to your green tick, orange triangle, and red cross images.

Formula that displays data if the word ends with particular string

I need a formula that, if the ItemDescription contains the words "Black Feet", displays "romano chair" without the word "Feet".
My current formula is:
if WorkOrder.ConfigProptext} like "*Feet*" then
How can I do this in Crystal?
To replace every instance of "Black Feet", use:
REPLACE({Table.ItemDescription}, "Black Feet", "Romano Chair")
If you want a condition returns true if the description contains "Feet", use:
INSTR({Table.ItemDescription}, "Feet") > 0

Setting up some properties for a combobox (scroll, edit, jump)

There are 3 properties that I want to set for some VBA form comboboxes and I don't know if it's possible.
I don't want to let the combobox editable. Right now if the user types something in it that it submits the form it will send that value... I want to let him choose only from the values I added in the Combobox.
I want to make the list of items in the combobox scroll-able. Right now I'm able to scroll through the list if I use the scroll-bar but I don't know why I can't scroll with the mouse scroll.
And I want to jump to some item if I start typing. Let's say I have the months of the year in one combobox... if I start to type mar I want it to jump to march. I know that for the html forms this properties is by default but I don't know about VBA forms...
Thanks a lot
Of the behaviours you want, some are possible with settings on the Combo, others you will need to code
List of Months: Put a list of entries on a (hidden) sheet and name the range. Set .RowSource to that range
Match as you type: Set properties .MatchEntry = fmMatchEntryComplete and .MatchRequired = True
Reject non list entries: A Combo with these settings will allow you to type an invalid entry, but will reject it with an error message popup when you commit. If you want to silently reject invalid data as you type, you will need to code it.
If you want the selected value returned to a sheet, set .ControlSource to a cell address (preferable a named range)
By "...scroll with the mouse scroll..." I assume you mean the mouse wheel. Unfortunatley Forms don't support mouse wheel scroll. You will have to code it yourself. There is a Microsoft patch for this at here (not tried it myself yet)
Sample code to silently reject invalid entries
Private Sub cmbMonth_Change()
Static idx As Long
Dim Match As Boolean
Dim i As Long
If cmbMonth.Value = "" Then Exit Sub
If idx = 0 Then idx = 1
i = idx
Match = False
For i = 0 To cmbMonth.ListCount
If cmbMonth.List((i + idx - 1) Mod cmbMonth.ListCount) Like cmbMonth.Value & "*" Then
cmbMonth.ListIndex = (i + idx - 1) Mod cmbMonth.ListCount
Match = True
Exit For
End If
Next
If Not Match Then
cmbMonth.Value = Left(cmbMonth.Value, Len(cmbMonth.Value) - 1)
End If
End Sub
Set the propertie MatchEntry of combobox to 1 (fmMatchEntryComplete) and MatchRequired to true for example
combobox1.MatchEntry=1
combobox1.MatchRequired=True
[]'s