Using Xbasic to Select a Record and Display a Form

Description

Button1 runs Xbasic code that loads the Invoice form to display the details of the invoice selected in the embedded browse.

Xbasic Code Run by the Button1 OnPushEvent

DIM zoom as P
zoom = :Form.load("Invoice", "", "InvoiceZoom")
zoom:tables:INVOICE_HEADER.filter_expression = "INVOICE_NUMBER = '" + inv_number.TEXT + "' "
zoom:tables:INVOICE_HEADER.query()
zoom.show()
zoom.activate()

An Explanation of the Code

The first line creates a pointer variable named zoom.

DIM zoom as P

This line loads the Invoice form and uses the variable zoom to refer to it.

zoom = :Form.load("Invoice", "", "InvoiceZoom")

This line sets the filter_expression property of the underlying table. The INVOICE_NUMBER field in the database must match the value of the inv_number field on the form. Although hidden, the inv_number field is an easy way to provide a value for the query to match.

zoom:tables:INVOICE_HEADER.filter_expression = "INVOICE_NUMBER = '" + inv_number.TEXT + "' "

Execute the query records against the underlying table.

zoom:tables:INVOICE_HEADER.query()

Now show the form.

zoom.show()

Now give the form focus.

zoom.activate()

See Also