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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking if a dataview is empty 1

Status
Not open for further replies.

amberlynn

Programmer
Dec 18, 2003
502
CA
Hello,
I'm having trouble with a dataview.
My code looks like this:

dv1 is declared public at the class level
then in my sub:
dv1 = New DataView
With dv1
.Table = DsCBLP1.Tables("TDT_CUT_BLOCK_LP")
.RowFilter = "ID_CUT_BLOCK = '" & txtBlockID.Text & "'"
End With

My textboxes are populated by this code:

Me.txtLPsiteFactor.DataBindings.Add("text", dv1, "STR_CRITICAL_FACTORS")

Often there is no data available to match the given filter. For the textboxes this is fine, there is no error, it just leaves the textboxes blank.

Where I'm running into trouble is when I'm using a variable, like this:
drvCBLP = dv1(0)
LPtype = drvCBLP("STR_TYPE")

This gives me an error if there is no data.
How can I get around this? Or test to see if there is data before executing the above code??

Thanks,
Sorry it's so lenthy,
amber
 
You can use Count

Code:
If ( dv1.Count() > 0 ) Then 

   drvCBLP = dv1(0)
   LPtype = drvCBLP("STR_TYPE")
End If

-Kris

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top