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

trouble with vb class obj return 1

Status
Not open for further replies.

butchkmd

Programmer
Nov 13, 2001
83
0
0
US
I am making a function in a class to return 2 fields from a table in SQL 7 this is the code

Public Function GetReCurChgs(strCustno As String) As String

Dim rsTemp As ADODB.Recordset

Set rsTemp = New ADODB.Recordset

rsTemp.Open "select chg_desc,chg_amt from rcufil where
acct ='" & strCustno & "'", _
CN, adOpenStatic, adLockReadOnly

Do While Not rsTemp.EOF
GetReCurChgs = Trim(GetReCurChgs) & vbNewLine
rsTemp.MoveNext
Loop

rsTemp.Close

Set rsTemp = Nothing

End Function


the trouble is all that returns is blanks in quotes (actually squares show in the debugger) I know the field names are right and the data is there... any suggestions?
 
All you're doing is adding a vbNewLine character to GetReCurChgs for every record returned. You never actually added the contents of the records to the string. Those boxes are the debugger's interpretation of vbNewLine characters.
Try this:
Do While Not rsTemp.EOF
GetReCurChgs = rsTemp.Fields("chg_desc") & vbNewLine
rsTemp.MoveNext
Loop


Maybe you wanted both fields to be added... either way, just don't forget to actually write the field to your string.
 
Oops.
Make that:
Do While Not rsTemp.EOF
GetReCurChgs = GetReCurChgs & rsTemp.Fields("chg_desc") & vbNewLine
rsTemp.MoveNext


plus it looks like you do want both fields.. maybe put a delimiter between them or something.
GetReCurChgs = GetReCurChgs & rsTemp.Fields("chg_desc") & "," & rsTemp.Fields("chg_amt") & vbNewLine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top