ODBC Select Query

Hi,

I have the following code for retrieving values from an ODBC connection and assigning these values to a field on a form. Part of my code is as follows. I am having trouble getting the actual values from the result set of the query.

Sub Click(Source As Button)

Dim con As ODBCConnection

Dim qry As ODBCQuery

Dim result As ODBCResultSet

Dim msg As String

Dim pername As String



Set con = New ODBCConnection

Set qry = New ODBCQuery

Set result = New ODBCResultSet

Set qry.Connection = con

Set result.Query = qry



con.ConnectTo("myodbc")	

msg = "SELECT perid, last_name  FROM person_name WHERE perid = " + pernum 



qry.SQL = msg

result.Execute

result.NextRow

pername = result.FieldName(last_name)

Messagebox " The Last Name is "+ pername		

End Sub

Subject: ODBC Select Query

Rika,

Your line which retrieves the value should be

pername=result.GetValue(“last_name”)

HTH

Mike

Subject: RE: ODBC Select Query

Hi Mike,

I have used this line in my code. pername=result.GetValue(“last_name”)

But when I check the value of pername in a MessageBox, the value is the word “False”, instead of the last name of the person.

Thanks,

Rika