Displaying a specific record

Hi,

Apart from using the search facility, is there a programatic way of displaying a specific record in the form.

For example, I want to be able to use a button to display a specific record on the screen.

Are there any macros or any other way that I can display a certain record without using the search box.

Thanks
razaw

Yes, you can add a sql part using a global variable like where myfield=[glob_mycondition]; When you use a button you can set a filter in the global and then redir to the same application. Then you will redo the select, but with the new condition.

Hi Albert,

Thanks for your quick response.

I kind of understand what you are saying but Can you please explain a little bit more for me to be clear on exactly what needs to be done.

If I put the where condition in the SQL part of the form like myfield=[glob_mycondition], would it not effect the form all the time and not just when I use the button?

And can you please show me how to set set the filter and redir to the same application.

Thanks
razaw

Yes, you will need to form the sql for a generic clause initially. I.e. in onapplicationinit. You need to play a bit with the global. Perhaps include the where clause into it. So initially you have a simple select, but on clicking the button, the where is included. I haven’t tried it: but there are also macro’s to modify the sql.

Suppose your app is called ‘myapp.php’.

Then at the php code of the button you get something like:

[glob_where]=‘where mycondition’;
sc_redir(myapp.php);

You can retrieve a record with the primary key in your form.

For example if you have a table customer and the primary key is cust_id, then in the Form - SQL - CLAUSE WHERE you put CUST_ID = [v_cust_id]

Thanks for your suggestions. I will test these out.

If I want to modify the sql statement and add a where clause dynamically to the sql which macro will I use.

would I use sc_exec_sql or sc_select_where

Is sc_select_where just for the grid and not for the form application?

You need the docs to decide that. I would opt for the global variable.

Iam getting a little confused on how to do a generic select in the onapplicationinit event.

Imagine I have a table called customers with two columns and two rows and customer id is the primary key.

customer_id customer_name
1 John
2 Paul

I know that the generic select would look like this: select customer_id, customer_name from customers;

But what code do I need to put in the onapplicationinit?

I don’t understand on how to select into the form fields.

Like when I say: select customer_id, customer_name from customers; how do I know that customer_id is going to be displayed into the customer_id field on the form and customer_name is going to be displayed into the customer_name field on the form.

It may sound really simple but I don’t know how to ensure that a select is displayed in the correct fields on the form.

Any example would be very useful.

thanks