Validate a button

Elite237

New Member
Hello, someone know how to validate a screen. What I want to do is that to the moment to press a button my procedure is executed in case it is proved, but them finds that there throws myself a box of text that says to me that did not find records. This is the code that I have in my button:

FIND M_polcostos.
IF AVAILABLE M_polcostos THEN
RUN costos.w(docs-x-pagar.pol_costo, docs-x-pagar.cve_empresa, docs-x-pagar.cve_zona, docs-x-pagar.a-o).
ELSE
MESSAGE "No se encontraron polizas de costos" VIEW-AS ALERT-BOX ERROR.

But say to me that more than a record of the table they were found by the unique find (3166).
 
The problem is here:

FIND M_polcostos.
IF AVAILABLE M_polcostos THEN

I know nothing about the table M_polcostos (is it a real table or temp-table? How is the data arranged?). But if the FIND is failing because more than one record is found, then that's where the problem is.

First off, you need to add NO-ERROR to suppress any standard progress errors from your find - you're dealing with the error yourself. Second, if it's a real table you should specify the locking (not needed on a temp-table).

Then, you need to decide what your FIND is trying to achieve. Do you only care that there is at least one record in the M_polcostos table? If so, you could use this:

Code:
FIND FIRST M_polcostos NO-LOCK NO-ERROR.
IF AVAILABLE M_polcostos THEN

If you need to find a specific record in the table, you'll need a where clause:

Code:
FIND M_polcostos WHERE M_polcostos.myField = "boingboing" NO-LOCK NO-ERROR.
IF AVAILABLE M_polcostos THEN

You may need to combine these two approaches if you need a FIRST with a WHERE, but you get the idea.

Not sure if this is enough to help, but it might get you started, so ask some more questions if you need to!
 
Top