Oracle Forms comparing two checkboxes status - oracle

I have a form that has two checkboxes, one is dup and one is sum. They both take values, add them up, and display the total in a display item. I have that part covered in an if statement on both checkboxes. What I need some assistance with, is a third if statement that, if sum is checked and the user checks dup, oracle forms pops up a message, uncheck the dup checkbox, and does nothing else. Here is the code I have so far :
IF :mn_outstanding_trans.cb_duplicate_activity ='Y' THEN
:mn_outstanding_trans.activity_cd := 'SUM';
:bl_control.gross_sum_of_trxs := :bl_control.gross_sum_of_trxs + :mn_outstanding_trans.gross_amt;
:bl_control.net_sum_of_trxs := :bl_control.net_sum_of_trxs + :mn_outstanding_trans.net_amt;
:bl_control.previous_activity_cd := :mn_outstanding_trans.activity_cd;
ELSIF :mn_outstanding_trans.cb_duplicate_activity ='N' THEN
:mn_outstanding_trans.activity_cd := ' ';
:bl_control.gross_sum_of_trxs := :bl_control.gross_sum_of_trxs - :mn_outstanding_trans.gross_amt;
:bl_control.net_sum_of_trxs := :bl_control.net_sum_of_trxs - :mn_outstanding_trans.net_amt;
:bl_control.previous_activity_cd := :mn_outstanding_trans.activity_cd;
END IF;

if sum is checked and the user checks dup, oracle forms pops up a message, uncheck the dup checkbox
It seems that you want to allow either DUP or SUM checkbox set, but never both. If that's so, then you should use a radio button instead of two checkboxes (which are supposed to exclude each other).
Also, maybe it would be easier to understand what you're talking about if you posted a screenshot of that form.

Related

Oracle Apex Checkbox Group Limit

This might be a silly one but haven't been able to figure it out.
I have a Checkbox Group Item (with Static info) with 4 different options, I want to limit the amount of checked boxes to just two. Is this something possible to make?
Thank you
A checkbox is submitted as a colon-separated string. APEX_STRING has lots of functionality to convert the string to a pl/sql collection (and back). Once converted you can use functions like FIRST, LAST, COUNT. Or even compare collections using INTERSECT. For checking a max nr, a COUNT is enough.
So the validation would be something like this (type Function Body returning Error Text):
DECLARE
l_arr apex_t_varchar2;
BEGIN
l_arr := apex_string.split(:P13_CHECKBOX,':');
IF l_arr.COUNT > 2 THEN
RETURN 'Can only select 2 values';
ELSE
RETURN NULL;
END IF;
END;

Excel Mac VBA Loop Through Cells and reset some values

I currently have a worksheet that I have multiple people filling out every day. There are 4 columns that the users fill out: C, E, H, & J (all numerical values, one row per day of the month.)
The users fill in C, E, & H every day no matter what, but a lot of days there is no value to put in column J. I need the value in J to be set to 0 if the user doesn't enter anything. Of course it would be easier to just have the users enter 0, but I'm working with a complicated group of people here.
Anyway, I want to use a macro that runs automatically when the user clicks the save button (before it actually saves, of course), and have it do the following: (I am more familiar with php, so I'm just typing this out how I'm familiar - I'm sure my syntax is incorrect)
Foreach Row
If "column A" != "" {
If "column J" != "" {
//Everything is good, continue on...
} else {
CurrentRow.ColumnJ.value == 0
}//Value has been set - continue loop
}
//column A is blank, this day hasn't come yet - quit looping here
End Foreach
If anyone could help me out with this I'd appreciate it. With some research, this is what I've come up with so far, and now I'm stuck…
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim curCell As Range
'Labor Flow Sheet'.Select
For Each curCell in Range( ???? )
If curCell.Value = "" Then
???????
End If
Next curCell
End Sub
Thanks in advance!
See this link about finding the right range, and as for the question marks inside the If statement, you would want to put
curCell.Value = 0
For the question marks in your statement
For Each curCell in Range( ???? )
Solution 1:
To find the full range you're working with, you'll need to use a column that is filled out each day. You mentioned columns C, E, and H were filled out every day. Using one of those columns (let's pick C for the example here), you could find the range by using the .end method. This goes out either up down left or right from a range until it doesn't find any data. So,
Range("J1", Range("C1").End(xlDown)).Select
will select all cells from J1 (or whatever column is the last in your sheet) to the bottom-most cell containing data in column C, automatically.
Solution 2:
Manually put in the range. For example, to choose A1 to J300:
Range("A1", "J300").Select

Visual Basic Function Procedure

I need help with the following H.W. problem. I have done everything except the instructions I numbered. Please help!
A furniture manufacturer makes two types of furniture—chairs and sofas.
The cost per chair is $350, the cost per sofa is $925, and the sales tax rate is 5%.
Write a Visual Basic program to create an invoice form for an order.
After the data on the left side of the form are entered, the user can display an invoice in a list box by pressing the Process Order button.
The user can click on the Clear Order Form button to clear all text boxes and the list box, and can click on the Quit button to exit the program.
The invoice number consists of the capitalized first two letters of the customer’s last name, followed by the last four digits of the zip code.
The customer name is input with the last name first, followed by a comma, a space, and the first name. However, the name is displayed in the invoice in the proper order.
The generation of the invoice number and the reordering of the first and last names should be carried out by Function procedures.
Seeing as this is homework and you haven't provided any code to show what effort you have made on your own, I'm not going to provide any specific answers, but hopefully I will try to point you in the right direction.
Your first 2 numbered items look to be variations on the same theme... string manipulation. Assuming you have the customer's address information from the order form, you just need to write 2 separate function to take the parts of the name and address, take the data you need and return the value (which covers your 3rd item).
To get parts of the name and address to generate the invoice number, you need to think about using the Left() and Right() functions.
Something like:
Dim first as String, last as String, word as String
word = "Foo"
first = Left(word, 1)
last = Right(word, 1)
Debug.Print(first) 'prints "F"
Debug.Print(last) 'prints "o"
Once you get the parts you need, then you just need to worry about joining the parts together in the order you want. The concatenation operator for strings is &. So using the above example, it would go something like:
Dim concat as String
concat = first & last
Debug.Print(concat) 'prints "Fo"
Your final item, using a Function procedure to generate the desired values, is very easily google-able (is that even a word). The syntax is very simple, so here's a quick example of a common function that is not built into VB6:
Private Function IsOdd(value as Integer) As Boolean
If (value Mod 2) = 0 Then 'determines of value is an odd or even by checking
' if the value divided by 2 has a remainder or not
' (aka Mod operator)
IsOdd = False ' if remainder is 0, set IsOdd to False
Else
IsOdd = True ' otherwise set IsOdd to True
End If
End Function
Hopefully this gets you going in the right direction.

Fast way to search lines of Tmemo

I have a TMemo on a form which allows users to enter a list of items. People can enter many items here. When they click Save the contents of the TMemo is checked and then added to the database.
I have a second list in a TStringList which I loop over and check to see if any of it's items are contained in the TMemo.
In a nut shell it looks like this
....
//slItems = TStringList
//mItems = TMemo
for i := slItems.Count -1 downto 0 do
begin
if mItems.Lines.IndexOf(slItems[i]) = -1 then
slItems[i].Delete;
end;
----
So stringlist looped, check to see if it exists in memo, if not delete from list.
However, with 200+ items this is starting to slow down a lot, and with 1000 it gets real bad.
Whats the fastest way to search a TMemo?
Read all of TMemo into a local TStringList and work from that. Every time you're accessing TMemo.Lines you're relying on Windows messaging to talk to the windows-provided multi line text box. Anything but efficient!
....
//slItems = TStringList
//mItems = TMemo
//L = TStringList
L.Text := mItems.Text; // edited per David's suggestion.
L.Sorted := True; // per Uwe Raabe's suggestion.
for i := slItems.Count -1 downto 0 do
begin
if L.IndexOf(slItems[i]) = -1 then
slItems[i].Delete;
end;
----

radio button group matlab

i have two set of button groups.
first button groups has two radio buttons and second group has four radio buttons.
if button 1 is selected in group1 and any one from the group 2. similarly for button2 in group 1 and any one from group2, respective function calls must be made on click of push button with these combinations. how to do it. there will be 8 separate function calls for their respective combinations. how to do the combination of button groups. switch case or if else statement did not work out?? kindly help.
Here is an idea.
First you create 2x4 cell array of your functions.
fnc_array = {fcn11, fcn12, fcn13, fcn14; fcn21, fcn22, fcn23, fcn24};
Then do switch case for each radio button in a group and return an index (say fcn_index1 for 1st group, and fcn_index2 for the 2nd group), which button selected.
Then you can call a function from your array with those indexes:
fcn_array{fcn_index1,fcn_index2}(arguments)
Switch and if..else should certainly work out, but you need to nest them, i.e. there's no way to switch on a pair of values.
switch valA
case 1
if isB
out = fcn11(args{:});
else
out = fcn12(args{:});
end
case 2
if isB
out = fcn21(args{:});
else
out = fcn22(args{:});
end
case 3
if isB
out = fcn31(args{:});
else
out = fcn32(args{:});
end
case 4
if isB
out = fcn41(args{:});
else
out = fcn42(args{:});
end
end
Not the greatest of style, but if they all use the same arguments then you could get away with dynamically building the call with the eval function based on which buttons were selected (using sprintf and the 'SelectedObject' field of the radio groups and a tag such as:eval(sprintf('func%s%s(args)',get(get(handles.group1,'SelectedObject'),'Tag'),get(get(handles.group2,'SelectedObject'),'Tag')))
(Could be combined with indexing the children using find(get(handles.group1,'Children')==get(handles.group2,'SelectedObject'))
and taking note of which is which)

Resources