Greetings: I run a referral nonprofit (mostly for support groups) and have constructed a db in Access. Now I need to take the data in the db and convert it into HTML for our new website.
There are 102 categories; each support group fits into one or more categories; when a client requests information, he/she is sent to the groups in one category. I have constructed a query so that I can put together a list of paragraphs for each category showing details about each group in that category. It operates by iterating through each row and concatenating paragraphs for each group in that category. Unfortunately, when I try to open the recordset for that query and make the strSQL the same as the SQL produced by the query designer, I get a vague error message requesting a label, statement, or end of statement. For starters here's the DAO approach with the SQL --
Code:
Private Sub cmdDesignSearchResultsHTML_Click()
' This sub iterates qryWebAllCatsTheirGroupsTheirPublicContacts for which groups belong in each category and which contacts belong to each group to develop the HTML for
' the search results page of the web site.
' Bring in an array of all categories 3 digit numbers to use in the loop
Dim CatNumberList(1 To 200) As Integer
Dim db As Database
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT tblCategories.OurNumber, tblCategories.ID_Category, tblCategories.NameInAccess FROM tblCategories ORDER BY tblCategories.OurNumber"
Set rs = db.OpenRecordset(strSQL)
' Check for no categories found in list in categories -- just here to prevent program from crashing in weird situation
If Not rs.EOF Then
rs.MoveFirst
Else: MsgBox "No category numbers found -- very strange. Please investigate.", vbOKOnly + vbCritical, "Something's very wrong!"
Exit Sub
End If
' Loop through SQL from qrySortCatOurNumberbyOurNumber to assign each 3 digit category number to the CatNumberList array
rec = 0
Do While Not rs.EOF
rec = rec + 1
CatNumberList(rec) = rs!OurNumber
rs.MoveNext
Loop
' Close everything for a reiteration
rs.Close
Set rs = Nothing
Set db = Nothing
rec = 0
' SQL from the qryWeballCatsTheirGroupsTheirPublicContacts copied here from design wizard's SQL page -- something's rotten in Denmark.
SELECT tblCategories.ID_Category, tblCategories.OurNumber, tblGroup_Contact_Join.Status, tblGroup_Contact_Join.GroupID, tblGroups.DisplayPosition, tblGroups.GroupName, tblGroups.Description, tblContacts.ID_Contacts, tblContacts.LastName, tblContacts.FirstName, tblContacts.Status, tblContactPhonePublic.Prelude, tblContactPhonePublic.PhoneNum, tblContactPhonePublic.PhoneExt, tblContactPhonePublic.Notes, tblContacts.ConfEmail, tblGroups.WSW_URL
FROM (tblGroups INNER JOIN (tblCategories INNER JOIN tblGroup_Category_Join ON tblCategories.ID_Category = tblGroup_Category_Join.CategoryID) ON tblGroups.ID_Group = tblGroup_Category_Join.GroupID) INNER JOIN ((tblContacts INNER JOIN tblContactPhonePublic ON tblContacts.ID_Contacts = tblContactPhonePublic.RefNum) INNER JOIN tblGroup_Contact_Join ON tblContacts.ID_Contacts = tblGroup_Contact_Join.ContactID) ON tblGroups.ID_Group = tblGroup_Contact_Join.GroupID
WHERE (((tblGroup_Contact_Join.Status)<>"Inactive"))
ORDER BY tblCategories.OurNumber, tblGroups.DisplayPosition DESC , tblGroups.GroupName;
.
I did some obvious things (running it first rather than second, changing the " to ' or "") but to no avail. Alas.
I'm new here and couldn't find a way to post a jpg screen shot of the query design, but when I plugged this SQL into a blank SQL screen for Access, poof, it worked perfectly and backwardsly created the same query structure I put forth in the designer. Hmmm...
Thank you for kind consideration -- and any suggestions where I have unfortunately and unintentionally broken protocol.
Dr.C.