Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error checking MSFlexGrids

Status
Not open for further replies.

mrrrl

MIS
Dec 26, 2001
179
0
0
US
Error checking MSFlexGrids.

I have several MSFG that the program uses to put data into from a database depending on what the user selects. The user selects a line in one MSFG and it then populate another MSFG. I am doing some error checking and can’t figure out how to stop the user from clicking in a blank MSFG and causing a Run Time Error ‘381 – Subscript out of range.

Any ideas?
 
Check if the clicked column contains any data. if contains display in other grid. try this...

if trim(MSFG.textmatrix(MSFG.row,MSFG.col)) <> &quot;&quot; then
<your code to display data in second grid>
end if


 
Another method would be to control the .rows property so that there are no empty rows to click on. In other words only have as many rows as you need. Thanks and Good Luck!

zemp
 
Thanks,

Here is what I have done and it works well. If the user clicks in a blank MSFlexGrid this cathces the error, tells the user and then exits the sub without crashing the program.

Private Sub MSFlexGrid1_Click()
On Error GoTo X_Error

Call Get_National_Data(MSFlexGrid1, MSFlexGrid4)
Exit Sub

X_Error:

If MsgBox(Err.Description, vbOKOnly) = vbOKOnly Then
Exit Sub
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top