G
Guest
this is more or less a pure coding problem in VB
I have a 'StudentSearch' form which has many criteria, Fname, Lname,
University, Course etc which are put in through text boxes or drop down lists
and the results of which appear in a listbox called Results.
This works fine except that ive got 7 queries for the rowsource of Result
which are defined through the following If..else statement
<!--
Dim Search As String
'if a uni is picked and a course is not then change the type of query
If (Not IsNull(Me![UniID])) And IsNull(Me![Course]) Then
Search = "studentsearch2"
Else
'find all the students in a building
If (Not IsNull(Me![Building])) And IsNull(Me![Block]) And
IsNull(Me![Flat]) And IsNull(Me![Room]) Then
Search = "StudentSearch3"
Else
'find all the students ina block in a building
If (Not IsNull(Me![Building])) And (Not IsNull(Me![Block])) And
IsNull(Me![Flat]) And IsNull(Me![Room]) Then
Search = "StudentSearch4"
Else
'Find all the students in a flat in a block in a building
If (Not IsNull(Me![Building])) And (Not IsNull(Me![Block]))
And (Not IsNull(Me![Flat])) And IsNull(Me![Room]) Then
Search = "StudentSearch5"
Else
'impliment the default search
Search = "studentsearch"
End If
End If
End If
End If
With Me![results]
.RowSource = Search
.Requery
End With
-->
Getting silly isnt it?
Its going to get worse cos ive been told that further criteria will be
added and that the users will want to be able to search for students in ever
more imaginative combinations of criteria.
How can i change this to a Select..Case statement?
With much thanks,
Amit
I have a 'StudentSearch' form which has many criteria, Fname, Lname,
University, Course etc which are put in through text boxes or drop down lists
and the results of which appear in a listbox called Results.
This works fine except that ive got 7 queries for the rowsource of Result
which are defined through the following If..else statement
<!--
Dim Search As String
'if a uni is picked and a course is not then change the type of query
If (Not IsNull(Me![UniID])) And IsNull(Me![Course]) Then
Search = "studentsearch2"
Else
'find all the students in a building
If (Not IsNull(Me![Building])) And IsNull(Me![Block]) And
IsNull(Me![Flat]) And IsNull(Me![Room]) Then
Search = "StudentSearch3"
Else
'find all the students ina block in a building
If (Not IsNull(Me![Building])) And (Not IsNull(Me![Block])) And
IsNull(Me![Flat]) And IsNull(Me![Room]) Then
Search = "StudentSearch4"
Else
'Find all the students in a flat in a block in a building
If (Not IsNull(Me![Building])) And (Not IsNull(Me![Block]))
And (Not IsNull(Me![Flat])) And IsNull(Me![Room]) Then
Search = "StudentSearch5"
Else
'impliment the default search
Search = "studentsearch"
End If
End If
End If
End If
With Me![results]
.RowSource = Search
.Requery
End With
-->
Getting silly isnt it?
Its going to get worse cos ive been told that further criteria will be
added and that the users will want to be able to search for students in ever
more imaginative combinations of criteria.
How can i change this to a Select..Case statement?
With much thanks,
Amit