How to Add values dynamically to a ocx combobox in progress 4gl - openedge

Trying to add values from a database field to an ocx combo box. In which if you type in the value , it gives you the matching values.

You can use the old "COM Object Viewer" to look at the ocx. Its found in the "ProTools".
CSCombo32.ocx is normally found under /bin/system. Only on 32-bit installs though.
There you can see that AddItem takes a string and a index. The index being optional.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
i = chCtrlFrame:CSCombobox:AddItem("Hello").
MESSAGE "Hello added at position " i VIEW-AS ALERT-BOX.
Getting the value is done by calling Value():
MESSAGE chCtrlFrame:CSCombobox:Value().

Related

pentaho report designer: if the value is null, then show a certain string

In my DB, some of values of a column (called status) are null, and if they are null, I want to show a String "canceled".
Guess I need to do it on Attributes - common -if-null but then don't know how to specify it.
Can anyone help me?
There are multiple options, as you said, Attributes - common - if-null on the field containing the status should do that, you can specify a String by entering it in the Value box. If your string disappears after unfocusing, click the ... while the Value entry is selected, that will launch a Popup-entrybox.
Alternatively, you could put that logic into your query
select coalesce(status, 'Cancelled')
from table
COALESCE
Evaluates the arguments in order and returns the current value of the first expression that initially doesn't evaluate to NULL. For example, SELECT COALESCE(NULL, NULL, 'third_value', 'fourth_value'); returns the third value because the third value is the first value that isn't null.
Some databases might have similar functions with different names, with Oracle e.g. there's nvl()

how to insert the field values in the connected openedge database when table and column names are given

I've retrieved the field names of a table by giving the table name directly (INS_TEST is the name of my table). I used columns _Field-Name, _Data-Type of the _Field system table and retrieved the field names and their data types.
I want to use the retrieved field names and insert field values into those fields.
FOR EACH _File WHERE _File-Name = "INS_TEST":
FOR EACH _Field WHERE _File-Recid = RECID(_File):
DISPLAY _Field._Field-Name.
DISPLAY _Field._Data-Type.
ASSIGN _File._File-Name._Field._Field-Name = 1 WHEN (_Field._Data-Type EQ "INTEGER").
END.
END.
But the ASSIGN statement gives an error. Suggestions please!
The following procedure takes a table name, a field name and a character value as parameters. It will update the field in question in the first record of that table with the value provided.
Obviously you could write a more sophisticated WHERE clause and do other things to fancy it up for your specific needs.
procedure x:
define input parameter tbl as character no-undo.
define input parameter fld as character no-undo.
define input parameter xyz as character no-undo.
define variable qh as handle no-undo.
define variable bh as handle no-undo.
define variable fh as handle no-undo.
create buffer bh for table tbl.
create query qh.
qh:set-buffers( bh ).
qh:query-prepare( "for each " + tbl ).
qh:query-open.
do transaction:
qh:get-first( exclusive-lock ).
fh = bh:buffer-field( fld ).
display fh:buffer-value.
fh:buffer-value = xyz.
end.
delete object bh.
delete object qh.
return.
end.
run x ( "customer", "name", "fred" ).
/* prove that we really did change it...
*/
find first customer no-lock.
display name.
Don't use the _field table for this. _file and _field (in fact, any table that starts with underscore) are your meta schema tables. They're your friends in learning dynamic programming or even understanding how your schema is currently defined, but I strongly recommend AGAINST trying to manipulate them yourself. And it doesn't really sound like you're trying to do that anyway, if I understand you correctly.
So once you have ins_test fields, you can do a static assign in a block (again, no need to query or cycle the underscore tables in this case):
CREATE ins_test.
ASSIGN ins_test.field1 = value1
ins_test.field2 = value2
ins_test.field3 = value3 NO-ERROR.
IF ERROR-STATUS:ERROR THEN DO:
/* Treat your error here */
END.
Or, if you're really looking into dynamic assigning (which is going to be harder given you're probably still starting), you need to study dynamic queries and dynamic buffers so you understand those, then you could create the record by getting a handle to the buffer, then assign the table using the BUFFER-FIELD attribute to cycle the field names.
Hope that helps.

bind parameter inside a lexical parameter oracle reports builder

Is there a way to use a bind parameter inside a lexical parameter query something like this?:
select col from tbl where col = :bind_param
note: the code above is an input in a lexical parameter
When saying a "lexical query", do you mean a "lexical parameter"?
If I understood you correctly, then yes - you can do that, by setting it in the After Parameter Form trigger. (BTW, that's where I set my lexical parameters' values, always).
Open Reports Online Help System and search for "lexical". It is very well described. I believe that this is what you are asking:
A lexical reference cannot be used to create additional bind variables
after the After Form trigger fires. For example, suppose you have a
query like the following (note that the WHERE clause is replaced by a
lexical reference):
SELECT ENAME, SAL FROM EMP
&where_clause
If the value of the where_clause parameter contains a reference to a
bind variable, you must specify the value in the After Form trigger or
earlier (*LF). You would get an error if you supplied the following value
for the parameter in the Before Report trigger:
WHERE SAL = :new_bind
If you supplied this same value in the After Form trigger, the report
would run.
(*LF) Now, that's somewhat contradictory - "or earlier" actually is the Before Report trigger, so ... take it with caution. As I've said (and I'll repeat it): I set lexical parameters' values in the After Parameter Form. Worked always (for me).

Ms Access AddItem with VBA

I have a Form that has a button on it. The button basically copies records from one Table to the other.
As records are read and copied, it is also checked for specific values. E.g. If one of the fields in the table has a value of "" then it should call another form that allows me to enter a date. Once the date is entered and the form is closed the programme carries on with copying.
It can also happen that the key fields in the table that is being copied are duplicate. In this case I should a 'listbox form' should be launched with a listbox displaying the values of the duplicate records. I should then select the correct record that I need copied.
Dim NumberCount As Long
NumberCount = RecordsetElementValue.RecordCount
If NumberCount > 1 Then
With Form_F_ListBox.List30
RecordsetElementValue.MoveFirst
Do
With Forms!F_ListBox.List30.AddItem(RecordsetElementValue!E_ElementValue)
End With
RecordsetElementValue.MoveNext
Loop Until RecordsetElementValue.EOF = True
DoCmd.OpenForm "F_ListBox", acNormal
End With
End If
The code sample above is what I have for in case there are duplicate records (NumberCount > 1)
The listbox in my F_ListBox form should be filled with the values in my recordset.
I now run into a runtime error 6014. The RowSourceType property must be set to 'Value List' to use this method.
What am I doing wrong?
The usual way to set the row source of a combo or list box in MS Access is to use an SQL statement, however, you can also use a list. This is controlled by the row source type.
Me.MylistBox.RowSourceType = "Value List"
From your notes, it seems that an SQL statement for the row source would be easier:
Me.MylistBox.RowSource = "SELECT ID FROM MyTable"

Converting Decimal In a Label to an Integer

Currently using VS2008, VB.NET, SQL.
I have a FormView from a Data Source that is getting some fields that are stored as Decimals in the SQL Database.
I am grabbing the field from the FormView as such:
Dim AvgTicketL As Label = CType(frmMerchantProfile.FindControl("F10Label"), Label)
I need to take this value, and convert it to an Integer, then send it along to an API. I have the API Calls done, tested and working, but I'm getting an error as when it is getting this value, the API is returning "Must be an Integer" error.
What I have tried so far:
Dim AvgTicketL As Label = CType(frmMerchantProfile.FindControl("F10Label"), Label)
Dim AvgTicket1 As Integer
AvgTicket1 = Double.Parse(AvgTicket.Text)
Do something with AvgTicket1
I have also attempted to Round the Value, then convert it and call it - no luck.
Checking the value of AvgTicket1 (Writing it out to a Label or Response.Write) shows "100", where the database value was 100.00. But the API is still getting 100.00, apparently. Any other conversion method that I've attempted states errors that the Label cannot be converted to Integer.
What are some methods I can successfully convert this value to an integer from a label?
The title of your question and the text of your question point to two different things.
Assuming you want to know how to safely convert the decimal value retrieved from the database, which is presumably the value of AvgTicketL, before calling your API you would do the following:
Create a variable of datatype Integer and use System.Int32.TryParse() to safely convert the decimal to an integer. Then pass that variable. (Code coming)
Dim testInt as Integer = -1
If System.Int32.TryParse(AvgTicketL.Text, testInt) Then
' Do something with testInt - call the API using the value
Else
' code to execute if the parse fails.
' This could be whatever you need the code to do if the value of AvgTicketL.Text can't be properly parsed into an Int value.
End If
After some fooling around this is what I was able to do to get this to work...
I took some of what David had said, and then just made a simple adjustment - I don't know why I hadn't thought of it earlier!
Dim AvgTicketL As Label = CType(frmMerchantProfile.FindControl("F10Label"), Label)
Dim AvgTicketI As Integer = "-1"
I dimmed a second variable as an int, then
AvgTicketI = CInt(AvgTicketL.Text)
From there, I just called AvgTicketI as the variable to pass to the API. Worked!
Thanks, David, for the guidance!

Resources