Three Questions implementations in a bound form?

miltiadis21

Junior Programmer
Local time
Today, 07:13
Joined
Jul 11, 2007
Messages
44
have three questions with choices Yes and no (or two options)
See my diagram-picture of how is planned
1. The first Question has two choices
1.1 Yes and no
1.2 If Yes is selected a Second question is spawned
1.3 if No is selected the same question is opened (Second question)
2. The Second Question is two same Questions (see diagram)
2.1 On the Second question in the first part if the answer is Yes a bound combobox is spawn and the user selects the appropriate method ( i need to keep there the value of yes in order to be used for calculations)
2.2 On the second Question in the first Part if the answer is No: we keep the value of no in order to be used for calculations
3.1 Repeats 2.1
(On the Second Question in the Second Part if the answer is yes a bound combobox is spawn and the user selects the method) It is the same process and bound combobox with the 2.1 method
3.2 On the Second Question in the Second Part if the answer is no Form closes without saving the record
When I am saying that I want to kept the value I mean I want the 1 ,2 of option group to be used in a query for example
Select Field
From Answers
where question = 1;
I am thinking not to use boolean fields but numeric fields to store them
How I am going to do this any hint suggestions?
 

Attachments

  • questionare.png
    questionare.png
    25.2 KB · Views: 162
Simple Software Solutions

In your decision tree you need to assisng a unique value to each option, such as 2, 4, 8, 16, 32, etc

Next depending on what the user has chosen add up all the known values together this should then give you another unique number. Store this number in your database.

Now when the record is processed or brought to screen you will have a function (To be created) that is a select case based on the unique value. So for example if I previously answered Yes to question 1 and no to part 2 then I would expect to se a value of 6 so in the select case statement if the incoming value is 6 I know what the results of the questions were.

Just remember to cover all eventualities.

In its purest term lets suppose we have two dates that the user could enter for a date range. however they have the facility to either enter an end date, start date, both dates or even no dates.

If the enter a start date then a value of 2 is assigned to start date
If the enter a end date then a value of 4 is assigned to end date

In theory we could have :

0 - no dates selected (use all)
2 greater or equal to start date
4 less than or equal to end date
6 (2+4) between start date and end date


Hope this makes sense::confused:

codeMaster::cool:
 
Can you provide me an example with the select Statement ?
i think i understood what you said but bare in mind that i am completely noob with this subject
Thanks
 
Simple Software Solutions

Ok,

So we first assign a value to each of the three main questions and if answered with a Yes the value is stored to a running total.

Q1 = 2
Q2 = 4
Q3 = 8


The user ticks Q1 and Q3.
So 2 + 8 = 10


The number 10 is stored in a field in the database for that record.

The user then selects that particular record

When the record is brought to the screen the on load event fires with:

Code:
Select Case Me.QValue [COLOR="SeaGreen"](Where Me.QValue is the no 10)[/COLOR]    
     Case 0  [COLOR="seagreen"]'- Q1 = False: Q2 = False : Q3 = False[/COLOR]    
     Case 2  [COLOR="seagreen"]'- Q1 = True : Q2 = False : Q3 = False[/COLOR]    
    Case 4  [COLOR="seagreen"]'- Q1 = False : Q2 = True : Q3 = False[/COLOR]    
    Case 6  [COLOR="seagreen"]'- Q1 = True : Q2 = True : Q3 = False[/COLOR]
    Case 8  [COLOR="seagreen"]'- Q1 = False : Q2 = False : Q3 = True[/COLOR]
    Case 10 [COLOR="seagreen"]'- Q1 = True : Q2 = False : Q3 = True[/COLOR]        
        Me.Quest1 = True
        Me.Quest2 = False
        Me.Quest3 = True
    Case 12 [COLOR="seagreen"]'- Q1 = True : Q2 = True : Q3 = True[/COLOR]
End Select


As long as you cover all permutations you should be able to tick/untick the check boxes accordingly.

When you come to save new/update the record you need to reverse the logic to derive a new value. A tip on how to do this is to place a default value in the tag property for each check box then prior to saving add up all the values where the ckeck boxes have been ticked.

Hope this make more sense

David
 

Users who are viewing this thread

Back
Top Bottom