Link to home
Start Free TrialLog in
Avatar of ccsbaby
ccsbaby

asked on

easy 125 pts...

I have a data grid and some command buttons.  When the data grid is empty some of the command buttons cause error.  I tried this:

If grdDataGrid is null then
MsgBox("Message here")
End if

I also tried to replace the 'is null' with '= ""'

This obviously does not work.  Can anyone give me a working way to do this?  Thanks
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ryan Chong
Hi ccsbaby,

How you connect the DataGrid, what is the associated DataSource?

Anyway, you can try to compare it with the DataSource of the DataGrid:

Example:

If Adodc.Recordset.RecordCount = 0 then
MsgBox("Message here")
'..
End if

..

regards
slow typing.. :P
Avatar of ccsbaby
ccsbaby

ASKER

Sorry guys...Its connecting to an Access 2000 DB
ADODB connection,   OLEDB 4.0, etc.
Ok, so just use ADORecordset.RecordCount ( assuming of course that you have used adOpenStatic or a CursorLocation of adUseClient to open the recordset - otherwise you wont get the proper record count).
have you tried

If grdDataGrid.DataSource.Recordset.EOF = true Then
    msgbox "GRID EMPTY"
Endif
Avatar of ccsbaby

ASKER

mhowling:

method or data member not found
Are you using a bound control/grid, or are you working with a disconnected recordset and populating the grid from within a procedure accessing the recordset object?

In your first column and first row, will there EVER an instance that the cell will empty?  You could check for data within a cell that will never contain an empty value, if properly populated.  If the cell returns a Null/Empty value, you know that your grid does not contain values.

Hope this "workaround" helps.
CArnold
Hi ccsbaby,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept TimCottee's comment(s) as an answer.

ccsbaby, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted.

Netminder
CS Moderator