Simulate LookupOk

Hello, I have a button LookupOk When a user push this button, I would to test for some error, If error, I return LookupCancel Else, LookupOk. How can I return LookupOk or LookupCancel in C/Side? Thx

Buttons OnPush() : IF NOT OK THEN BEGIN MESSAGE(‘Something wrong.’); ACTION::Cancel; END ELSE BEGIN ACTION::OK; CurrForm.CLOSE; END;

Thx, But That don’t work Form.Runmodal return always ‘Close’ and not ‘Ok’ or ‘Cancel’ (And for lookup I think it’s lookupOk and LookupCancel, but that don’t work to)

Hi Geoffrey, I am not sure what kind of form you have. To run a form in lookup mode you have: if SomeFormVariable.runmodal = Action::LookUpOK then begin //do something end; You can test for cancel as well (check the option for the Action System variable). If you have a regular form and just want to see if the user pressed OK or Cancel on that you can make some global in form and set it to false to start with. Then OnPush of that Button set the global to True Also in that Form make a function that when called returns the value of this global So then in the calling code you do: clear(SomeFormVar); SomeFormVar.runmodal; if SomeFormVar.GetGlobalValue = true then begin //Do something end; clear(SomeFormVar); I hope this helps

Property PushAction must be <0> (the default value), NOT “LookupOk” or “OK”! Im am using the code mentioned on a form - and it works…

Hello, Thx for your reply but I don’t have solution. I don’t use global variable and function because this form is use many time as normal lookup form, so I wouldn’t change it. My button have no push action, it’s <0> My code on button (sorry msg are in french :))): IF choix = 1 THEN BEGIN IF “Date plannifiee” = 0D THEN BEGIN MESSAGE(‘Cet entretien n’‘a pas encore été planifié’); ACTION::LookupCancel; END ELSE BEGIN ACTION::LookupOK; END; END; CurrForm.CLOSE; On form that do the run : choix.LOOKUPMODE(TRUE); choix.SETRECORD(liens); choix.SETTABLEVIEW(liens); MESSAGE(’%1’,choix.RUNMODAL); … message is always ‘close’ (If I dont’ display msg and test, it’s only true with close) Thx

Hi Geofrrey, Let us try a different way. Can you explain what functionality you are trying to achieve. Maybe there is another way … Cristi

I Think the best way is a global function … I change it Thx

Buttons OnPush() : IF NOT OK THEN BEGIN MESSAGE(‘Something wrong.’); ACTION::Cancel; END ELSE BEGIN ACTION::OK; CurrForm.CLOSE; END; The code above, given by Anfinnur, is something I would like to use. However, when I try this I am getting a message saying ‘there is a syntax error’, on the line ACTION::OK; . (I have removed all the code in the OnPush event, except for this line and still get the problem). Am I missing something here?

Peter: Strange! The code was originally done in 2.60. Later on I imported the object into 3.60; and it works here as well. But I cannot compile the object in 3.60 - get the same error as you. Don’t know why…