W
Wullie
I'm sure I'm missing something simple in this, but needs some help.
I have a form with 3 drop-down combo-boxes, which a subform is populated
with a list of questions (which has another subform which will populate the
answer, but not got that far yet) from the selections made from the
drop-downs.
I had a look around and found
http://www.microsoft.com/office/com...a49c&mid=1ea934e4-8065-49ed-b9f6-814fd63ea49c helpful to start me on my way.
I have made a few adjustments (to filter on 3 selections rather than 1) and
created the following code
---------------------
Private Sub QuestionCategoryType_AfterUpdate()
Dim QuestionSchoolType As String
Dim QuestionAreaType As String
Dim QuestionCategoryType As String
Const strcStub = "SELECT Question FROM QuestionResolution "
Const strcTail = " ORDER BY QuestionResolution.Question;"
If Not IsNull(Me.QuestionSchoolType) Then
QuestionSchoolType = "WHERE (SchoolTypeID = """ &
Me.QuestionSchoolType & """)"
End If
If Not IsNull(Me.QuestionAreaType) Then
QuestionAreaType = " AND (AreaID = """ & Me.QuestionAreaType & """)"
End If
If Not IsNull(Me.QuestionCategoryType) Then
QuestionCategoryType = " AND (CategoryID = """ &
Me.QuestionCategoryType & """)"
End If
Me.OpenQuestionsQuery.Form.RecordSource = strcStub & QuestionSchoolType
& QuestionAreaType & _
QuestionCategoryType & strcTail
End Sub
---------------------
When I change the 3rd drop-down, I get a 'Constant Expression required'
error, highlighted on strcStub in the section of the
Me.OpenQuestionsQuery.Form.RecordSource line.
Any advice as to why this is not getting picked up as a Constant, after
being declared as such further up, would be greatly appreciated.
Thanks
I have a form with 3 drop-down combo-boxes, which a subform is populated
with a list of questions (which has another subform which will populate the
answer, but not got that far yet) from the selections made from the
drop-downs.
I had a look around and found
http://www.microsoft.com/office/com...a49c&mid=1ea934e4-8065-49ed-b9f6-814fd63ea49c helpful to start me on my way.
I have made a few adjustments (to filter on 3 selections rather than 1) and
created the following code
---------------------
Private Sub QuestionCategoryType_AfterUpdate()
Dim QuestionSchoolType As String
Dim QuestionAreaType As String
Dim QuestionCategoryType As String
Const strcStub = "SELECT Question FROM QuestionResolution "
Const strcTail = " ORDER BY QuestionResolution.Question;"
If Not IsNull(Me.QuestionSchoolType) Then
QuestionSchoolType = "WHERE (SchoolTypeID = """ &
Me.QuestionSchoolType & """)"
End If
If Not IsNull(Me.QuestionAreaType) Then
QuestionAreaType = " AND (AreaID = """ & Me.QuestionAreaType & """)"
End If
If Not IsNull(Me.QuestionCategoryType) Then
QuestionCategoryType = " AND (CategoryID = """ &
Me.QuestionCategoryType & """)"
End If
Me.OpenQuestionsQuery.Form.RecordSource = strcStub & QuestionSchoolType
& QuestionAreaType & _
QuestionCategoryType & strcTail
End Sub
---------------------
When I change the 3rd drop-down, I get a 'Constant Expression required'
error, highlighted on strcStub in the section of the
Me.OpenQuestionsQuery.Form.RecordSource line.
Any advice as to why this is not getting picked up as a Constant, after
being declared as such further up, would be greatly appreciated.
Thanks