trying to get value from a column in a table

catbollu

Member
Joined
Dec 15, 2004
Messages
5
Programming Experience
1-3
I am trying to get the value from one column in an access table to a variable and display certain things based on what is in that field.
The code I have that is not working :) is below.
<code>
OrderInfo.Visible = True

OrderInfo.Text = ordersgrid.SelectedItem(1)

medbatch = ordersgrid.SelectedItem(2)

Me.MedinfoDS1().Clear()

If ordersgrid.SelectedIndex <> -1 Then

Me.medinfoda2.SelectCommand.Parameters(0).Value = medbatch

Me.medinfoda2.Fill(Me.MedinfoDS1)

Dim condition As String

condition = MedinfoDS1.Tables(0).Columns("[Time]").ToString

Select Case condition

Case "Amt."

amount.Visible =
True

AmountTXTbox.Visible = True

Case "B/P"

BloodPressure.Visible =
True

bloodpressuretxtbx.Visible = True

Case "B.S."

amount.Visible =
True

AmountTXTbox.Visible = True

Case "LT."

BloodPressure.Visible =
True

bloodpressuretxtbx.Visible = True

Case "Pulse"

amount.Visible =
True

AmountTXTbox.Visible = True

Case "RATE"

BloodPressure.Visible =
True

bloodpressuretxtbx.Visible = True

Case "Resp"

amount.Visible =
True

AmountTXTbox.Visible = True

Case "Site"

BloodPressure.Visible =
True

bloodpressuretxtbx.Visible = True

Case "Temp"

BloodPressure.Visible =
True

bloodpressuretxtbx.Visible = True

End Select

Label15.Visible = True

Notelbl.Visible = True

reasontext.Visible = True

NoteTxt.Visible = True

End If

End Sub
</code>

 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
A good way to trace the error is to add breakPoints to your code and step thru to debug.

This line:
condition = MedinfoDS1.Tables(0).Columns("[Time]").ToString
will always set the value of condition to Nothing. The brackets don't work in this case.
However, if you were to lose the brackets:
condition = MedinfoDS1.Tables(0).Columns("Time").ToString
condition would always get the value "Time" since the ToString function of a column returns its name.
I beleive what you're after is something like this:
condition = MedinfoDS1.Tables(0).Rows(0).Item("Time").ToString
 
Top Bottom