-
May 28th, 2001, 11:52 AM
#1
Thread Starter
Addicted Member
VSFlexGrid from VideoSoft - How to validate data?
Hi,
How can I validate the data being added to a VSFlexGrid, before they are commited to my database?
How event should I use?
Note: This Grid is made by VideoSoft.
Thanks in advance,
Michel Jr.
-
May 28th, 2001, 12:18 PM
#2
PowerPoster
You can validate as the user types by using the ValidateEdit event. This came straight from the Help file...
Fired before the control exits cell edit mode.
Syntax
Private Sub VSFlexGrid_ValidateEdit( ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)
Remarks
This event is fired before any changes made by the user are committed to the cell.
You may trap this event to read the contents of the cell editor with the EditText property and to make sure the entry is valid for the given cell (Row, Col). If the entry fails validation, set the Cancel parameter to True. The changes will be discarded and the control will remain in edit mode.
If you want to validate keys as they are typed into the editor, use the KeyPressEdit or the ChangeEdit events. For more details on in-cell editing, see the Editable and ComboList properties.
For example, the code below shows a typical handler for the ValidateEdit event. In this case, column 1 only accepts strings, and column 2 only accepts numbers greater than zero:
Code:
Sub fg_ValidateEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)
Dim c$
Select Case Col ' different validation rules for each column
Case 1 ' column 1 only accepts strings
c = Left$(fg.EditText, 1)
If UCaseS(c) < "A" And UCase$(c) > "Z" Then Beep: Cancel = True
Case 2 ' column 2 only accepts numbers > 0
If Val(fg.EditText) <= 0 Then Beep: Cancel = True
End Select
End Sub
-
May 29th, 2001, 08:44 AM
#3
Thread Starter
Addicted Member
One more question:
How can I assing a Field from my table to the VSFlexGrid columns?
Note: This is the syntax for the standard Microsoft DataGrid:
DataGrid1.Columns(0).DataField = Adodc1.Recordset.Fields("Name").Name & ""
What is the syntax for the VSFlexGrid?
Thanks again...
Michel Jr.
-
Feb 5th, 2025, 12:58 AM
#4
Member
Re: VSFlexGrid from VideoSoft - How to validate data?
Setting Cancel to True in the ValidateEdit event always causes a loud beep on ending the Sub. I never found a way round it.
-
Feb 7th, 2025, 09:45 AM
#5
Hyperactive Member
Re: VSFlexGrid from VideoSoft - How to validate data?
 Originally Posted by LittleTyke
Setting Cancel to True in the ValidateEdit event always causes a loud beep on ending the Sub. I never found a way round it.
I've never seen that behavior in FlexGrid. That's why the code above manually adds the beep, since FlexGrid doesn't have it's own noise after Validate. But I never use ValidateEdit, just Validate.
-
Feb 7th, 2025, 10:07 AM
#6
Member
Re: VSFlexGrid from VideoSoft - How to validate data?
If you only use Validate, how do you validate an edited cell in the FlexGrid? This is what ValidateEdit is intended for.
-
Feb 7th, 2025, 10:13 AM
#7
Hyperactive Member
Re: VSFlexGrid from VideoSoft - How to validate data?
I checked a little closer, and the code was actually doing BeforeEdit (save value) AfterEdit (restore old value if a bad value was entered). Probably to get around the doorbell sound in ValidateEdit.
-
Feb 7th, 2025, 10:23 AM
#8
Re: VSFlexGrid from VideoSoft - How to validate data?
I guess the sound is there for people who can't see very well, and/or who are "pro" data-entry types who don't look at the screen while typing (looking instead at the physical document they are copying data from). These people need to know when they've mistyped something without seeing it on the screen.
Anyone who doesn't like the sound can clear the Critical Stop sound option in Windows Sound settings:
-
Feb 7th, 2025, 05:08 PM
#9
Member
Re: VSFlexGrid from VideoSoft - How to validate data?
Actually, in one application I wrote, which also produced this annoying beep, I used the Windows API to disable sound just before the point in the code where the sound originated, and reinstated the previous setting just after. Worked fine, though a really big hammer to crack a nut. It's all very well disabling critical stop, but other programs may indeed justifiably want it.
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
|