Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

cell validation - beforeUpdate or poschanging?

I've historically used poschanging for any cell validation, which works well by the way (certainly far better than poschanged) but I'm looking at the beforeUpdate event and can't quite grasp which would be the recommended event for validating user input.
I suspect I've always used poschanging because I was used to poschanged and this was an improvement over those flaws.
I feel like I've been down the beforeUpdate path previously but can't remember why I wouldn't stick with it. From the description it seems like the place to validate but I also feel like I'm missing something.

Comments

  • In order for BeforeUpdate or PosChanging to work properly you must qualify your events synchronously. If you are doing that, then is there a reason you aren't using the OnInvalidData event handler instead? If for some reason OnInvalidData can't work for you, then BeforeUpdate is the better event.
  • OnInvalidData - I've never used the cellconv property for some reason; a decision also made some time ago and just never revisited. Probably because much of the cell validation I do is validating against a list of keys and then if valid, populate other fields in the table.
    That said, I did try it just before penning this post. I wanted a simple validation; a quantity column to contain a number so I set the cellconv validation property to "MDO".
    Regardless of what I entered in the cell, the invaliddata message just kept popping up, so I thought I'd just revert back to old habits but with a view to changing the event if appropriate.
  • I'm not sure if you are looking for further help to get the OnInvalidData event to work as expected. If so, please let me know and I'll try to sort this out with you.

    If not, then I still suggest you use the BeforeUpdate event as your next best option. Likewise, the AfterUpdate event is what you should use for formatting the data. OnPoschanging should only be used to prevent navigation based on business rules. OnPoschanged is helpful for implementing a default value in the cell getting focus.
  • Thanks for the clarification, best practice guide @DonBakke. That helps greatly.
    With that guidance I revisited the cellconv and set it to skip the message and fire the OnInvalidData event so I could capture what it was working with. I assume I'm overlooking something simple but here's what the debugger shows me
    P2 looks like a number to me but I must have my blinkers on
  • So I'm going to rework the window I'm working on to implement beforeUpdate and afterUpdate events instead of poschanging and see how that goes. If anyone can identify what I'm doing wrong with the cellconv property then I'll implement that too.
  • Can you post your code that sets the CellConv property?
  • cellValidation = "MD24" cellConversion = null$ cellValidMsg = "Quantity must be a number" showMessage = false$ Set_Property(ole_itemTable$, "OLE.CellConv[":QtyCol$:"; All]", cellValidation:fm$:cellConversion:fm$:cellValidMsg:fm$:showMessage)
  • @AusMarkB - I can't duplicate your problem. For comparison purposes, can you change "MD24" to "D" and see if it allows a valid date to be entered?

    What version of SRPControls.ocx are you using?
  • Dates didn't work either.
    With or without a conversion value.

    4.0.3

    I can manage it with the beforeupdate event but curious that it doesn't seem to work for me. It doesn't look that difficult to implement
  • Agreed. I'm still happy to help resolve this but I think the next step is to have you send me a copy of your app or schedule an online support session.
Sign In or Register to comment.