Progression Bars.

J

jonesfranckandi

hi everyone

I wish to have a progression bar that is displayed on a form in access.
I have a quiz form to do in access and the requirements are they are 5
questions and each time you answer a question the bar starts filling
showing the questions you have left. Something like after answering the
first question the bar is filled at a a fifth and two questions two
fifth and so on. I know this can be done but I seek help. If anyone has
something similar that involves progressions bars I will be happy to
accept it. A download example would be helpful.
Would anyone give me the help I need Please!!

Thanks in advance!!!!!!
 
T

tina

if all the answers are stored in a single record in the form's underlying
table, then here's one way to do it:

1. add a Rectangle control to your form.
name it "recOutline" (without the quotes, of course).
set the BackStyle property to Transparent.
set the SpecialEffect property to Sunken.
2. copy recOutline (the easy way is to select it, then press Ctrl+c on your
keyboard, then Ctrl+v).
name the new rectangle "rec5".
set the Visible property to No.
set the BackColor property to whatever color you want the progression bar to
be. set the BorderStyle to Transparent.
move rec5 directly on top of recOutline, so it "fills" the outline of that
box.
3. copy rec5.
name the new rectangle "rec4".
assuming you want a horizontal progression bar that fills from left to
right, drag the *right* side of rec4 to the left until it is 20 percent
smaller than rec5.
move rec4 directly on top of rec5, lining up the left side of the box with
the left side of rec5.
4. copy rec4. name the new rectangle "rec3", make it 20 percent smaller than
rec4, and move it on top of rec4, lining it up as above.
5. copy rec3. name the new rectangle "rec2", and repeat the above.
6. copy rec2. name the new rectangle "rec1", and repeat the above.

now you have six Rectangle controls on the form, with the five colored ones
decreasing in size in 20 percent increments, layered on top of the "outline"
Rectangle, with all boxes lined up on the left edge. if you open the form in
Form view, you'll only see the "empty" outline box.

go back to Design view, and click the Code button on the toolbar. in the VBE
window that opens, click Tools | Options | Editor tab and put a checkmark
next to Require Variable Declaration (if it's not already checkmarked). then
click OK. look at the top large white are of the VBE window; it should have
two lines that read

Option Compare Database
Option Explicit

if either one is missing, type it in, so it shows exactly as above. directly
under the Option Explicit statement, paste the following code, as

Private Function isTrackProgress()

Dim col1 As New Collection
Dim var1 As Variant
Dim col2 As New Collection
Dim var2 As Variant
Dim i As Integer

col1.Add Me.rec1
col1.Add Me.rec2
col1.Add Me.rec3
col1.Add Me.rec4
col1.Add Me.rec5

For Each var1 In col1
var1.Visible = False
Next var1

col2.Add Me!TextA
col2.Add Me!TextB
col2.Add Me!TextC
col2.Add Me!TextD
col2.Add Me!TextE
' replace TextA, TextB, etc., with the
' correct names of the five controls on
' your form.

For Each var2 In col2
If Not IsNull(var2) Then i = i + 1
Next var2

If i > 0 Then col1(i).Visible = True

End Function

look at the pasted code, and follow the instructions that show up in green
letters. close the VBE window. in the form Design view, select all five of
the "quiz answer" controls at one time. in the Properties box, the title bar
should say "Multiple selection". click the Event tab, and paste the
following expression into the AfterUpdate event line, as

=isTrackProgress()

save the form, and close.

the progression bar is completely dynamic. each time a question is answered,
the bar "imcrements" by 20 percent, regardless of the order in which the
questions are answered. if an answer is deleted, the bar "decrements" by 20
percent.

hth
 
E

efandango

Tina,

How would that work with a Next Record feature?. I have a table of 10
questions. On the form, when the user guesses an answer (via a combo box),
the form progresses to the next question, regardless of whether they are
correct or not.
How would I tie your progress meter into my form?
 
E

efandango

Tina, I tried to use your code in a form for a quiz (see previous message).
But when I put the lines:

Option Compare Database
Option Explicit


and try to run my control button used to select an answer, I get a 'variable
not defined' error message in the VBA window.

what am i doing wrong?
 
T

tina

re-read the caveat at the beginning of my previous post. if your 10
questions are in 10 *records*, then the solution i posted will not work for
you.

hth
 
T

tina

(see my response to previous message.) Option Explicit requires that all
variables in all modules in the database be explicitly declared; you will
get the posted error message if 1) a variable anywhere in your database
modules has not be explicitly declared, or 2) if you declared a variable,
but then misspelled it when using it in a procedure. in the second case,
Access won't tell you that it's "spelled wrong", because it sees it as an
entirely different variable, that is not declared explicitly.

hth
 
E

efandango

I did read that, but wasn't sure how someone would store multiple answers in
a single record. Though I'm not experienced anough with access to know how.
My table has 10 questions in 10 seperate records from a single table. Is
their another way of doing it with that kind of setup?.

Maybe I can have each segment appear each time the record is advanced. It is
a permantly fixed based number of records, at the moment the record advances
with a macro nextrecord command which doesn't repeat 'loop' style., so I
guess it doesn’t know when/how to fill-in the next progress segment.

Is there a way of doing it in code, bearing in mind that the number of
records is a finite 10?

This is my macro:

Condition: [Combo_Answer]=[Run_point_Address_A]
Action: SetValue
Item: [Answer_box]
Expression: "Yes"

Condition: [Combo_Answer]<>[Run_point_Address_A]
Action: SetValue
Item: [Answer_box]
Expression: "No"

Action: SetValue
Item: [Scorebox]
Expression: [Scorebox]= [Scorebox]+1

Action: NextRecord
Item: Form
 
E

efandango

Here’s what I did on a form bound to a finite 10 record table. Be aware that
this will only work with a finite number of records.

Method

First place an unbound control on your form. This will be a record
placeholder for your current record number. In this case it is
[Your_Control_Name]

‘(Now create the number of rectangles you will want for your progression bar
and make them Invisible.)

Call them rec1, rec2, rec3, and so on…

Now add this following code to your Form’s ‘On Current’ property.

Private Sub Form_Current()
Me.RecordsetClone.Bookmark = Me.Bookmark
Me.Your_Control_Name = Me.RecordsetClone.AbsolutePosition + 1

‘(This gets the Form’s current Record Number for [Your_Control_Name])


‘(Adjust/remove the number of [rec]tangles that you will need in the code
sections below, in this example I wanted 10, for the number of finite records
in my table.

‘(Now add the following code in the same code section as the code above.)

If Me![Your_Control_Name] = 1 Then
Me![rec1].Visible = True
Me![rec2].Visible = False
Me![rec3].Visible = False
Me![rec4].Visible = False
Me![rec5].Visible = False
Me![rec6].Visible = False
Me![rec7].Visible = False
Me![rec8].Visible = False
Me![rec9].Visible = False
Me![rec10].Visible = False

End If


If Me![Your_Control_Name] = 2 Then
Me![rec2].Visible = True
Me![rec3].Visible = False
Me![rec4].Visible = False
Me![rec5].Visible = False
Me![rec6].Visible = False
Me![rec7].Visible = False
Me![rec8].Visible = False
Me![rec9].Visible = False
Me![rec10].Visible = False

End If


If Me![Your_Control_Name] = ‘next control number in your sequence…’
Me![rec3].Visible = True
Me![rec4].Visible = False
Me![rec5].Visible = False
Me![rec6].Visible = False
Me![rec7].Visible = False
Me![rec8].Visible = False
Me![rec9].Visible = False
Me![rec10].Visible = False

End If

End Sub


The ‘Me![rec#].Visible = False’ code lines are for when you click your
records backwards, which makes the progression go back down the scale. If you
only want the progression bar to go up, then just delete the
‘Me![rec#].Visible = False’ lines.
 
T

tina

another solution might be to create an unbound form, and add the progress
meter controls to it. add the "real" form as a subform. depending on how the
data is stored and how the interface is built, you might be able to use an
unbound textbox control (txtCount) in the main form, with DCount() function
in the ControlSource, to count the number of "answered" questions in the
current group of 10 records (in the subform), and show/hide the bars
accordingly. in the *subform's* Current event procedure, something along the
lines of

With Me.Parent
!txtCount.Requery
!RecNumOne.Visible = !txtCount = 1
!RecNumTwo.Visible = !txtCount = 2
...
!RecNumTen.Visible = !txtCount = 10
End With

hth


efandango said:
Here's what I did on a form bound to a finite 10 record table. Be aware that
this will only work with a finite number of records.

Method

First place an unbound control on your form. This will be a record
placeholder for your current record number. In this case it is
[Your_Control_Name]

'(Now create the number of rectangles you will want for your progression bar
and make them Invisible.)

Call them rec1, rec2, rec3, and so on.

Now add this following code to your Form's 'On Current' property.

Private Sub Form_Current()
Me.RecordsetClone.Bookmark = Me.Bookmark
Me.Your_Control_Name = Me.RecordsetClone.AbsolutePosition + 1

'(This gets the Form's current Record Number for [Your_Control_Name])


'(Adjust/remove the number of [rec]tangles that you will need in the code
sections below, in this example I wanted 10, for the number of finite records
in my table.

'(Now add the following code in the same code section as the code above.)

If Me![Your_Control_Name] = 1 Then
Me![rec1].Visible = True
Me![rec2].Visible = False
Me![rec3].Visible = False
Me![rec4].Visible = False
Me![rec5].Visible = False
Me![rec6].Visible = False
Me![rec7].Visible = False
Me![rec8].Visible = False
Me![rec9].Visible = False
Me![rec10].Visible = False

End If


If Me![Your_Control_Name] = 2 Then
Me![rec2].Visible = True
Me![rec3].Visible = False
Me![rec4].Visible = False
Me![rec5].Visible = False
Me![rec6].Visible = False
Me![rec7].Visible = False
Me![rec8].Visible = False
Me![rec9].Visible = False
Me![rec10].Visible = False

End If


If Me![Your_Control_Name] = 'next control number in your sequence.'
Me![rec3].Visible = True
Me![rec4].Visible = False
Me![rec5].Visible = False
Me![rec6].Visible = False
Me![rec7].Visible = False
Me![rec8].Visible = False
Me![rec9].Visible = False
Me![rec10].Visible = False

End If

End Sub


The 'Me![rec#].Visible = False' code lines are for when you click your
records backwards, which makes the progression go back down the scale. If you
only want the progression bar to go up, then just delete the
'Me![rec#].Visible = False' lines.



tina said:
(see my response to previous message.) Option Explicit requires that all
variables in all modules in the database be explicitly declared; you will
get the posted error message if 1) a variable anywhere in your database
modules has not be explicitly declared, or 2) if you declared a variable,
but then misspelled it when using it in a procedure. in the second case,
Access won't tell you that it's "spelled wrong", because it sees it as an
entirely different variable, that is not declared explicitly.

hth


on
your progression
bar to of
that box
with smaller
than colored
ones the
VBE checkmarked).
then should
have five
of title
bar "decrements" by
20 answering
the anyone
has
 

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