combo box on a form, I want it to list the maximum number of marks

G

Guest

I have a combo box on a form, I want it to list the maximum number of marks
allowed for a task. So in tbltask table I have set the following:

Task Name Max Mark
Task1 3
Task2 10

So on a form will have the task1 and task2 listed on the it and I want the
combo box next to the task to list all of the marks up to and including the
maximum mark:

e.g.

Student Name Task Mark (Combo box would list the following numbers)
a Task1 1,2,3
b Task2 1,2,3,4,5,6,7,8,9,10
c Task1 1,2,3
 
S

Scott McDaniel

I have a combo box on a form, I want it to list the maximum number of marks
allowed for a task. So in tbltask table I have set the following:

Task Name Max Mark
Task1 3
Task2 10

So on a form will have the task1 and task2 listed on the it and I want the
combo box next to the task to list all of the marks up to and including the
maximum mark:

You'd have to add code to the Form's Current event to reset the combo's .RowSource each time, something like this:

Private Sub Form_Current()

Dim i As Integer

Me.Combo1.RowSource = ""
Me.Combo1.RowSourceType = "Value List"

For i = 1 To Me.[Max Mark]
Me.Combo1.RowSource = Me.Combo1.RowSource & CStr(i) & ","
Next i

End Sub

This assumes that [Max Mark] is available from the form's Recordsource ... if not, you'd need to get the value somehow.

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
M

Marshall Barton

Matt said:
I have a combo box on a form, I want it to list the maximum number of marks
allowed for a task. So in tbltask table I have set the following:

Task Name Max Mark
Task1 3
Task2 10

So on a form will have the task1 and task2 listed on the it and I want the
combo box next to the task to list all of the marks up to and including the
maximum mark:

e.g.

Student Name Task Mark (Combo box would list the following numbers)
a Task1 1,2,3
b Task2 1,2,3,4,5,6,7,8,9,10
c Task1 1,2,3


If I understand your situation correctly (doubtful), I would
use another table (named Numbers) with one field (named Num)
and populated with records 1, 2, . . . up to more than the
maximum number of tasks you will ever have (99?)

Then set the combo box's Row Source to a query like:

SELECT Num
FROM Numbers INNER JOIN tbltask
ON Num <= Mark
WHERE [Task Name] = Forms![your form].[Task Name]

Then you can use BOTH the form's Current event and the Task
selection control's AfterUpdate event to requery the combo
box:
Me.[the combo box].Requery
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top