Help! Why does this not work?

paultax

Registered User.
Local time
Today, 16:25
Joined
Dec 3, 2007
Messages
30
Hi
I have a form split into pages, for a questionnaire. The questions are A1, A2, A3, B1,B2 etc.. and the A questions are on Page1, B on Page 2 etc.
All the questions derive from the same Table.
To answer the questions, I've used radio buttons which return a numerical value 1 to 5.
Now here's the problem
I want to make sure people answer all the questions on page 1 before being able to move to page 2.
Access being as it is, automatically sets each radio button to its lowest value.

What I want to do is set each question To Null on the Form Load event.
I've put this code behind the Click event of the button which moves you on to the next page

If A1.Value = Null Then
MsgBox "Please answer all the questions"
Exit Sub
Else
DoCmd.MoveToControl "Option104" (this is on second page)
End If

Now for some reason this just doesnt work, and stepping through, even though A1.Value does = Null, it skips straight to the Else.

I also need it to check A2 and A3.

Am I being really stupid here??
 
If you are using an option group, you don't have to have it set the lowest as default. Just go into the properties dialog and remove the value from the DEFAULT property of the GROUP and don't consider in code the individual values, but the value of the option GROUP itself.
 
I dont have any default value set, but unless I set it to Null on the Form Load event, it always seems to have a value.
The reason I want it as null, is to have a way of checking that someone has answered the question.
Any other way of doing this, I would be very grateful
Paul
 
Actually, it WON'T have a default value if you pull the default value off of the GROUP control instead of looking at the individual controls.

See, in the wizard when you set up an option group, you do not have to choose a default:

opgroupwiz01.png



And if you don't choose a default, then it looks like this when you open up the form:

opgroupwiz02.png


To fix it so it doesn't have the default you use this:

opgroupwiz03.png
 
That isnt really the problem Bob.
The problem is that despite these values being Null, I cant get an event to capture that.
 
In fact, part of the problem may be that one of the values returned by my option groups is zero, which happens to be the value returned by the option group from the wizard when you chose not to have a default (oddly enough).
 
It sounds like you are not asking for the right thing. You need to check the option GROUP value, not the individual items within the group.

So, this

If IsNull(Me.YourOptionGroupNameHere) Then
...etc.
End If
 
Using your If IsNull(Me. etc etc) Then WORKS!
Why my amateur version didnt is beyond me...

Thanks Bob
For your info, try creating an Option box to return a zero, and no default value. You'll see it doesnt work. Its a glitch i guess
 
Just one more thing, what is the correct syntax for adding a number of things to check (A1, A2 and A3)??
 
An option box either has a value or it is null. But, you cannot test for if something is EQUAL to null because null isn't anything and as such it cannot be tested for as being equal to anything. So you need to use the IsNull function to determine whether something is null or not.

You cannot assign an option group to be equal to 0 because that is a value and an option group either has a value, which if it does it is one of the selections, or it is null (none of the values selected). But you can set it to be a default value of one of the existing options.
 
Just one more thing, what is the correct syntax for adding a number of things to check (A1, A2 and A3)??

What is A1, A2, and A3? Are those individual values within an option group?
 
No A1, A2 etc are questions which each have their own option groups. Dont worry about that question, I've figured it out.
My problem here is that the values returned from the option groups go into a formula which gives you a score at the end of the questionairre. In order to calculate the scores, I either have to change all the values from the options boxes from 5 down to 1, and then subtract 1 at calculation time, or use A1 = Null A2 = Null at the from Load event (which is a lot easier - i think).
 
I still may not be understanding correctly, but with the calculations, you can use the NZ function to replace a null with a 0 (or whatever value you want).
 

Users who are viewing this thread

Back
Top Bottom