Looping ? (1 Viewer)

Matt Brown

Registered User.
Local time
Today, 20:44
Joined
Jun 5, 2000
Messages
120
Hi all,
Can anyone help me with this:
I have six option frames on a page which when selected need to trigger one text box to say either "Completed" or "Outstanding".

Ie if all of the frames were clicked over to the Yes position giving a value of "1" then the text box on the previous screen should read "Completed".
If one of the options was in the "No" position giving a value of 2 then the text box on the other screen should read Uncompleted regardless of the other 5 options saying completed.
Basically its all or nothing.

I have the following VBA for a straightforward "one option frame", my problem is how do i check all six option frames to see if all six are showing Yes in one go, now i have thought about using a loop statement but not sure of the best one to use, i have even looked at the "Collection " statement but ran into difficulties there.

Code is as follows (For a single option frame) :

If Frame14.Value = 1 Then
[Forms]![frmCustChangeReq]![Status] = "Completed"
Else
If Frame14.Value = 2 Then
[Forms]![frmCustChangeReq]![Status] = "Outstanding"
End If
End If

Hope someone can help me with this ...please..

Matt
 

cogent1

Registered User.
Local time
Today, 20:44
Joined
May 20, 2002
Messages
315
Why are you using Option groups if this is a YES/NO scenario?:confused:
 

Matt Brown

Registered User.
Local time
Today, 20:44
Joined
Jun 5, 2000
Messages
120
Re: Option groups

The option groups give me a quick an easy way of letting the user input an answer if the particular task has been completed.
The value is then stored and triggers actions off further down the line.

What would you suggest i use instead of option groups, just the actual option buttons, what is wrong with using the option groups?

confused

Matt
 

cogent1

Registered User.
Local time
Today, 20:44
Joined
May 20, 2002
Messages
315
What I mean is, why not use Yes/No check boxes. These are either True or false, which is simpler to test for. Your task can be done either with option groups or Yes/no fields, but I was curious to know why you chose option groups.

How many option groups, and their names?
 

Matt Brown

Registered User.
Local time
Today, 20:44
Joined
Jun 5, 2000
Messages
120
Re: Option groups

I can now see where you are coming from, i suppose i could have used the yes/no Check Boxes for this but just decided on using the option groups instead.
I normally do things the hard way! :rolleyes:
I have 6 option frames on one form.

Do you have an answer on this?

Matt
 

cogent1

Registered User.
Local time
Today, 20:44
Joined
May 20, 2002
Messages
315
Yes. Say you have six frames and all the all the frames are set to 1, (COMPLETED) then their SUM will be 6.

If one or more of the groups is set to 2, the sum will exceed 6.

Therefore, you only need to set the default value of each option group to 2 (NOT COMPLETED) and each time a job completes this sum will decrement by 1. When it reaches 6, you've completed all the jobs.

So the key lines in your code are

MyOptions=[ Frame1]+[Frame2].....up to frame6

IF MyOptions >6 then Forms!My Form!MyText="Not Complete" Else Forms!MyForms!MyText="Done"

It is not necessary to loop through the frames or or use the Value keyword.

Let's know how you get on..
 

Matt Brown

Registered User.
Local time
Today, 20:44
Joined
Jun 5, 2000
Messages
120
re:

That sounds very feasible. :)
i have now finished work for the day but will pick this up first thing in the morning.
thanks for the advice, i will let you know how i got on.
Matt
 

dgoulston

Hasn't Got A Clue
Local time
Today, 20:44
Joined
Jun 10, 2002
Messages
403
i agree i think the yes/no (toggle) button would be best, then all you have to do is have an if statement to say if all

If Toggle0.Value = -1 And Toggle1.Value = -1 (put rest here up to 6) Then
[Forms]![frmCustChangeReq]![Status] = "Completed"
Else
[Forms]![frmCustChangeReq]![Status] = "Outstanding"
End If



and then thats it,, it will work fine,,


DAL
 

Matt Brown

Registered User.
Local time
Today, 20:44
Joined
Jun 5, 2000
Messages
120
Thanks dgoulston for your input on this
Okay you guys have convinced me, i'll change the option groups to toggle yes/no buttons.
I am about to code this up so ill post here if all went well.
cheers
Matt
 

Users who are viewing this thread

Top Bottom