Sorting Browser question

cbrandon63

New Member
I know this has to be a very basic question and I apologize, but I'm a rookie ... I have a browse that is based on table A. Table A contains an employee number. I then go to table B to get the employee name. How do I get the browse to sort on the name?
 
U did NOT say, UR environment/version details
Basically U require a trigger event, I will assume it is GUI
On a button trigger, on choose / on click event, this is where U require a procedure.
So the button has the required code to specify a where requirement,
This then opens the query with the new where requirement.
The open query WHERE will force the browse to populate rows that satisfy the new query.
This is just a guide. It is hard to be more specific without UR environment details.
Good luck.
Bog up
 
If it is just the query you are struggling with then the following may help:

Code:
DEFINE TEMP-TABLE ttA NO-UNDO
   FIELD customer_id AS INTEGER LABEL "ID"
INDEX ttAix IS UNIQUE PRIMARY customer_id.

DEFINE TEMP-TABLE ttB NO-UNDO
   FIELD customer_id    AS INTEGER     LABEL "ID"
   FIELD customer_name  AS CHARACTER   LABEL "Name"
INDEX ttBix IS UNIQUE PRIMARY customer_id.

CREATE ttA. ttA.customer_id = 1.
CREATE ttA. ttA.customer_id = 2.
CREATE ttA. ttA.customer_id = 3.
CREATE ttA. ttA.customer_id = 4.

CREATE ttB. ASSIGN ttB.customer_id = 1 ttB.customer_name = "One".
CREATE ttB. ASSIGN ttB.customer_id = 2 ttB.customer_name = "Two".
CREATE ttB. ASSIGN ttB.customer_id = 3 ttB.customer_name = "Three".
CREATE ttB. ASSIGN ttB.customer_id = 4 ttB.customer_name = "Four".

DEF VAR hbr AS HANDLE.
DEF VAR hfr AS HANDLE.
DEF VAR hq AS HANDLE.

CREATE FRAME hfr ASSIGN
   WIDTH = 75
   HEIGHT = 10
   VISIBLE = TRUE
   .

CREATE QUERY hq.
hq:SET-BUFFERS( TEMP-TABLE ttA:DEFAULT-BUFFER-HANDLE, TEMP-TABLE ttB:DEFAULT-BUFFER-HANDLE ).
hq:QUERY-PREPARE( "FOR EACH ttA, FIRST ttB WHERE ttB.customer_id = ttA.customer_id BY ttB.customer_name" ).
hq:QUERY-OPEN(). 

CREATE BROWSE hbr ASSIGN
   TITLE = "Customers"
   FRAME = hfr
   QUERY = hq
   WIDTH = 74
   HEIGHT = 9
   VISIBLE = TRUE
   SENSITIVE = TRUE
   .
hbr:ADD-LIKE-COLUMN( "tta.customer_id" ).
hbr:ADD-LIKE-COLUMN( "ttb.customer_name" ).  

WAIT-FOR CLOSE OF THIS-PROCEDURE.

DELETE OBJECT hq.
 
If users do not have to be able to change the sort order by clicking the column headers then it is easiest to just open the browse query with a BY in it for the field you want to sort on.
 
Back
Top