Results 1 to 4 of 4

Thread: Cancel in ValidateEdit event of vsFlexGrid causes beep

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2015
    Location
    England
    Posts
    46

    Cancel in ValidateEdit event of vsFlexGrid causes beep

    My library program (Visual Basic 6.0) consists mainly of a vsFlexGrid with multiple columns for Title, Author, Borrowed Date, Return Date. I want to edit the Return Date in situ by making the cell editable, then typing a modified date.

    Consider the following code snippet:

    ' NB: CurrentBorrowedDate is in another column in the grid

    With flx
    NewValue = .EditText

    Case .ColIndex("ReturnDate")
    If IsDate(NewValue) Then
    If CDate(NewValue) >= CDate(CurrentBorrowedDate) Then
    ' Update the database
    rsLoanHistory("LH_ReturnDate") = NewValue
    rsLoanHistory.Update
    Else
    MsgBox "Return Date cannot be before Borrowed Date"
    Cancel = True ' <------- Problem arises here
    End If
    Else
    MsgBox "Invalid date format"
    End If
    End With

    It works fine, BUT ! The use of Cancel = True when the new date is wrong or invalid causes a loud system beep and there is no way I've found to suppress it.

    Has anyone got an answer for this annoyance?

    Edit note: Having submitted this, I see that the indenting has been lost! But the code is still okay.

  2. #2
    Fanatic Member
    Join Date
    Nov 2011
    Posts
    805

    Re: Cancel in ValidateEdit event of vsFlexGrid causes beep

    What procedure is it in. If in a KeyPress event then you can

    ie

    Public Sub VSFlexigrid_Keypress(Keyascii as long)

    Keyascii =0 ' << this supresses the ding

    end if

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2015
    Location
    England
    Posts
    46

    Re: Cancel in ValidateEdit event of vsFlexGrid causes beep

    It's in Private Sub flx_ValidateEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)

    ValidateEdit is the recommended event for validating edits in the vsFlexGrid.

  4. #4
    Fanatic Member
    Join Date
    Nov 2011
    Posts
    805

    Re: Cancel in ValidateEdit event of vsFlexGrid causes beep

    Quote Originally Posted by LittleTyke View Post
    It's in Private Sub flx_ValidateEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)

    ValidateEdit is the recommended event for validating edits in the vsFlexGrid.
    i use Vsflexigrid and dont really use the validate procedure.

    i use the keypress event to check what i am editing as i type or you can use the AfterEdit procedure to then do another check.
    If the data is incorrect , force it back to edit mode and let user know

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width