Getting data from a ListBox

mo9rissat

Registered User.
Local time
Today, 14:23
Joined
Jul 18, 2012
Messages
18
Hello,

I have a column Mark where I type students' marks. In a form I want to display those marks in a list box.But i want to display only if the mark <10 or >= 10 to simplify the filters. To do this I feed the list box (Mark) from a query where I put the following SQL:
Code:
SELECT DISTINCT IIf(Student.Mark<10 "<10",IIf(Student.Mark>=10,">=10","NULL")) AS Mark FROM Student;

For events, I want that once the user clicks on a line, ie selects the note <10 or > = 10 That is to say: the event After update , a macro is executed in order to open a form where we display all the fields in the table corresponding to the selected record in the list box. For this I use the macro Open Form and in the where clause I put:
Code:
[Forms]! [Form1]! [Liste0] = [Forms]! [StudentsForm]! [Mark]

But when I run, it displays an empty form. I know I'm getting errors somewhere. Can someone help me please?
 

Thank for your Help.

The code you gave me is in VBA, I prefer to work with macros (because I am poor in VBA).

when I feed my listbox from a sql query like:

Code:
select Mark from student;

and in macro "open form" executed by the button, in the where clause I put:

Code:
[MyQuery]! [Mark] = [Forms]! [Form1]! [Lst2]

Where Form1 is the form where I put my controls and lst2: the control name, it works very well. Once I select a record and click Submit, the second form opens and displays only the records with the same criteria selected in the listbox.

But I don't want to display records as they are in the listbox, I just want to display intervals, as Mark<10, Mark> = 10 and Null

when I feed my listbox from such a query:
Code:
SELECT DISTINCT IIf (Student.Mark <10 "<10", IIf (Student.Mark> = 10, "> = 10", "NULL")) FROM Student AS Mark;

And I select a value and then I click on the submit button to show me information in details about students with a score like the one selected. The second form opens but in the fields there is that "????" and in the mark's field they are records like <10 ....

But this is not the result I want.

I hope, I clearly explained the problem
 
To make things simple for you, put the IIF() function in the Record Source of your form as well, then filter under that field.
 

Users who are viewing this thread

Back
Top Bottom