NetTalk Central

Author Topic: Add code under Change button  (Read 4420 times)

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Add code under Change button
« on: April 09, 2012, 02:53:49 AM »
On a standard browse form with a Change button added to the row, what embed point would I use to add code to check for a value in the record and then cancel the action if not satisfied? Have spent about 3 days trying to find this out with no success at all.

IOW Click on Change (for example), run some code and if a condition is not satisfied then cancel the action and return to the Browse. It would also be nice if I could set an Alert here to indicate that the User cannot perform the action.
Thanks

John

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Add code under Change button
« Reply #1 on: April 09, 2012, 05:27:26 AM »
>> On a standard browse form with a Change button added to the row, what embed point would I use to add code to check for a value in the record and then cancel the action if not satisfied? Have spent about 3 days trying to find this out with no success at all.

preUpdate routine in the form.
Set ans=0 (as I recall) to abort the action.

>> It would also be nice if I could set an Alert here to indicate that the User cannot perform the action.

why are you showing them the button if they're not allowed to click it? Rather put a condition on the button so it's only displayed when pressing it makes sense.

cheers
Bruce

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: Add code under Change button
« Reply #2 on: April 09, 2012, 08:06:54 AM »
Welll Bruce I agree and this really goes back to all my recent questions but have not had the time to create the example. Maybe I could try explaining again?

I have a Browse of Invoices. Let's keep it simple for now and forget it used to be controlled by a Memory Form.

So when you open the browse there is a Gray highlight on the first record. However, that record has NOT been selected.

So on my button I have a condition say Hide if  p_web.GSV('InvoiceID') = ''

So first time in the button is hidden which is OK. Now I need the User to click in the browse. When they do I have code which sets InvoiceID.

The problem is at this stage I need to refresh the page to action the condition on the button.

The thing is, the browse never highlights/selects the record. The confusing thing for the user is the LIGHT GRAY color makes it look as though it is selected. You have to p[hysically click in the browse to select a  record.

I set the code in the embed point UserClickedOnARowInTheBrowse. That sets the SSV fine. However, I now need to refresh the page or the button to make the button conditional code work.

HTH

John

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: Add code under Change button
« Reply #3 on: April 09, 2012, 08:09:46 AM »
Also Bruce please note this is a BROWSE. There is no preUpdate.

FORMS are fine, I have plenty of code hiding buttons now.

Why ona  browse? I have an email button which I want them to use only if a value has been set on the invoice. Hence click on the invoice line and if the value is there then show the button otherwise hide/disable it.

HTH

John

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Add code under Change button
« Reply #4 on: April 09, 2012, 08:01:28 PM »
>> Maybe I could try explaining again?

you can try, but I suspect if you want an accurate, direct, answer then an example is the best explanation of what you are trying to do.

cheers
Bruce

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: Add code under Change button
« Reply #5 on: April 09, 2012, 10:29:15 PM »
OK Bruce - will take time out today to get an example done.

Thanks

john