MS Access VBA Recordset

armesca

Registered User.
Local time
Today, 04:10
Joined
Apr 1, 2011
Messages
45
I have a recordset pulling 50 columns from a 100 column table for one record; i want to pull all fields from the recordset if not null and append the column header to the value as well; I am having issues looping through; Any help is greatly appreciated!

Sample UNTESTED CODE - Just a thought; not sure if it will work

mysql = "SELECT tblmeta.metaIndividual,tblmeta.metaCompany, 48 more fields,
FROM TblBEPull INNER JOIN" _ where PaymentID =" & Me.lst_outgoing & ""

Set rst = CurrentDb.OpenRecordset(mysql, dbOpenDynaset)

Do While rst.EOF
for rst(0) to rst(50)
If rst.fields.value <> "" Then
myheader = rst.Fields.Name
myvalue = rst.fields.vaue
mystring = myheader & "," myvalue

'End If

'Loop


Not sure if I need the rst.eof since I am only analyzing one record. Thanks in advance
 
So what prevents you from running the code? I can assure you Access does not blow up its surroundings!

BTW: "I am having issues" is content-free. If you have something specific you want help with then say what it is, what line, what error message, and someone will surely help you.
 
Here is my solution; figured out my "issue"


With rst
.MoveFirst

For Each fld In rst.Fields
If mystring = "" Then
If fld.Value <> "" Then
mystring = "[" & fld.Name & "]" & fld.Value
End If
Else
If fld.Value <> "" Then
mystring = mystring & ", " & "[" & fld.Name & "]" & fld.Value
End If
End If
Next fld
End With
 

Users who are viewing this thread

Back
Top Bottom