Populating a Text control from SQL statement

  • Thread starter Thread starter Istari
  • Start date Start date
I

Istari

I'd like to insert the result of an SQL query into a text field on a form.
My problem is that although my SQL works perfectly, the text control is
being updated with the actual Statement as opposed to the result. I'm sure
this must be something really silly that I'm overlooking.

my code looks as follows:

Dim sRateName As String

sRateName = "SELECT [RateTypes].[RateName]" & _
"FROM Rates INNER JOIN RateTypes ON
[Rates].[RateTypeID]=[RateTypes].[RateTypeID]" & _
"WHERE [Rates].[RateID] = " & Me.RateID

Me.AccBasisText = sRateName
 
using dao

dim MySQLString as string 'holds the sql command
dim rRs as dao.recordset 'holds the data retrieved
mysqlstring=>"SELECT [RateTypes].[RateName]" & _
"FROM Rates INNER JOIN RateTypes ON
[Rates].[RateTypeID]=[RateTypes].[RateTypeID]" & _
"WHERE [Rates].[RateID] = " & Me.RateID

set rrs=currentdb.openrecordset(MYSQLSTRING)
if rrs.recordcount>0 then 'values present
Me.AccBasisText.value=
nz(rrs.fields("RateName"),"") 'assign
else
Me.AccBasisText.value ="none" 'assign litterally
end if
rrs.close 'free the recordset to minimize locking
set rrs=nothing

mind the wordwrap

had no time for testing it
 
Back
Top