Hello,
Using Access 2003 I am trying to loop through a query, dim each record as a string, Ignore all Nulls, concatenate the fields together, and then Dim all smaller stings into a LargerString.
Query Name: ReviewSFQ (The below code is pulling ALL records from a table, I’d like to change it to this query as it has a criteria set to eliminate unwanted fields)
PropDescription: Field I want to return. There might be anywhere from zero to 10 records with Null values mixed in.
After looping through I might have one field to Dim:
PD1 = “Blah Blah Blah”
LargerString = PD1
I might have no fields
PD1 = Null
LargerString = “”
I might have four fields
PD1 = “Blah Blah Blah”
PD2 = “Ya Ya Ya”
PD3 = Null
PD4 = “Blah de Blah”
LargerString = PD1 + PD2 + PD4
Here is the code I started:
Dim I As Integer
Dim db As Database
Dim rs As Recordset
Dim LargerString As String
Set db = CurrentDb
Set rs = db.OpenRecordset("StorefrontTable") <-How do I change this to run from a Query?
For I = 0 To rs.RecordCount - 1
Debug.Print rs.Fields("PropDescription")<- How do I change this from the Immediate foot note section into a usable place?
rs.MoveNext
Next I
rs.Close
Set rs = Nothing
db.Close
End Sub
Note: I was able to get a few lines onto a field, but kept getting a Null error and had to start over.
Any help given to solve any of the numerous problems I’m having would be greatly appreciated.
Using Access 2003 I am trying to loop through a query, dim each record as a string, Ignore all Nulls, concatenate the fields together, and then Dim all smaller stings into a LargerString.
Query Name: ReviewSFQ (The below code is pulling ALL records from a table, I’d like to change it to this query as it has a criteria set to eliminate unwanted fields)
PropDescription: Field I want to return. There might be anywhere from zero to 10 records with Null values mixed in.
After looping through I might have one field to Dim:
PD1 = “Blah Blah Blah”
LargerString = PD1
I might have no fields
PD1 = Null
LargerString = “”
I might have four fields
PD1 = “Blah Blah Blah”
PD2 = “Ya Ya Ya”
PD3 = Null
PD4 = “Blah de Blah”
LargerString = PD1 + PD2 + PD4
Here is the code I started:
Dim I As Integer
Dim db As Database
Dim rs As Recordset
Dim LargerString As String
Set db = CurrentDb
Set rs = db.OpenRecordset("StorefrontTable") <-How do I change this to run from a Query?
For I = 0 To rs.RecordCount - 1
Debug.Print rs.Fields("PropDescription")<- How do I change this from the Immediate foot note section into a usable place?
rs.MoveNext
Next I
rs.Close
Set rs = Nothing
db.Close
End Sub
Note: I was able to get a few lines onto a field, but kept getting a Null error and had to start over.
Any help given to solve any of the numerous problems I’m having would be greatly appreciated.