|
-
Feb 5th, 2025, 05:24 AM
#1
Thread Starter
Member
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.
-
Feb 5th, 2025, 06:43 AM
#2
Fanatic Member
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
-
Feb 5th, 2025, 07:04 AM
#3
Thread Starter
Member
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.
-
Feb 5th, 2025, 07:10 AM
#4
Fanatic Member
Re: Cancel in ValidateEdit event of vsFlexGrid causes beep
 Originally Posted by LittleTyke
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|