Option Box Problem

Dumbfounded

Registered User.
Local time
Yesterday, 22:22
Joined
Jul 26, 2007
Messages
92
Hi Guys,

I've got a form with 3 option boxes but they have to be checked and I can't seem to find where to do this in the properties. No set of option boxes can be left blank so I need it to come up with a warning - any ideas?

Thanks in advance.

Donna x :confused:
 
No set of option boxes can be left blank so I need it to come up with a warning - any ideas?
Like, a warning to tell the user that they cannot proceed if any of them are unchecked???
Code:
On_EventOfChoice

  If Me.Option1 = False Or Me.Option2 = False, etc... Then
    MsgBox "All of the Option Buttons Need to be Checked!!"
  End If
 
Hi Donna,
Form validation is done in the Form's BeforeUpdate event. Access has CheckBoxes and Option Groups. To which control are you referring?
 
Option Boxes

Hi Guys,

There are 29 questions and each question has 3 check boxes in an option group i.e. Yes, No, N/A (obvious only one of these can only be checked at any one time) but I don't want any of the 29 questions missing out.

Thanks

Donna x
 
Thanks Donna,
As I said earlier, you will need to put code in the BeforeUpdate event of the form to make sure each control has been completed.
 
RuralGuy,

Wouldn't you want the AfterUpdate event?

That way the msgbox or whatever she uses to alert that the box(es) are unchecked pops up?
 
Flipping heck!

Hi Guys,

Not sure what I'm doing wrong (I don't write VBA so it could be anything really). I've gone into the design view and I've clicked on the option boxes seperately as it didn't seem to want to do it for all the questions.

I've entered it as follows:-

Private Sub Frame127_BeforeUpdate(Cancel As Integer)
If Me.Option130 = False Or Me.Option132 = False Or Me.Option134 Then MsgBox "You have not answered this question"
End If
End Sub

But what I'm getting when I test it is taken back to the code screen with the error message:-

Compile Error:
End If without block If

I've looked on help but it's not helping, i.e. I can't see what I'm doing wrong. I've got the If and I've got the bit in the middle and I've got the End If but it's not happy with that. I know that you VBA people are going to be laughing at what is probably relatively simple for you guys but I'm at a complete loss - this is the hate part of the love/hate databases relationship isn't it!

Thanks

Donna x :(
 
I think that you forgot the = False in the last me.Option134 part..

Code:
Private Sub Frame127_BeforeUpdate(Cancel As Integer)
If Me.Option130 = False Or Me.Option132 = False Or Me.Option134 (Forgot the = False) Then 
        MsgBox "You have not answered this question"
End If
End Sub
 
RuralGuy,

Wouldn't you want the AfterUpdate event?

That way the msgbox or whatever she uses to alert that the box(es) are unchecked pops up?
You can cancel the BeforeUpdate event of a form so that the record is not saved until you are satisfied with all of the entries. The AfterUpdate event of the form is too late and can not be canceled.
 
Private Sub Frame127_BeforeUpdate(Cancel As Integer)
If Me.Option130 = False Or Me.Option132 = False Or Me.Option134 Then MsgBox "You have not answered this question"
End If
End Sub

But what I'm getting when I test it is taken back to the code screen with the error message:-

Compile Error:
End If without block If


Donna x :(
You received the error because you used a single line If...Then statement with an extra End If on another line. I prefer to use multi-line If...Then code so there is a CarriageReturn after the Then and the MsgBox statement would be on the next line followed by the End If on the following line like so:
Code:
Private Sub Frame127_BeforeUpdate(Cancel As Integer)
   If Me.Option130 = False Or Me.Option132 = False Or Me.Option134 Then
      MsgBox "You have not answered this question"
   End If
End Sub
 
Donna,
Have you bound each of your OptionGroups to a separate field in the RecordSource of the form? Is it a numeric field? Did you leave the default value empty?
 
Hi Guys,

I'm not blonde honestly, but I'd forgotten the last 'false' on all lines - copy and pasting you see. However that's not stopped the problem, neither has splitting my lines.

My Option Groups are bound to its relevant question (control source is the relevant question, i.e. Q1 links to options 112, 114 & 116 and so on). The option group itself are not numeric fields and have no default values listed, however the radio boxes themselves have values in them.

I don't know why clients have to be soooo picky! lol.

Thanks,

Donna x
 
Well Donna, you have lost me with that last post. I have no idea how one binds a control to a question in Access. If you open up the Properties of an OptionGroup control and switch to the Data tab, is there anything in the ControlSource property?
 
Control Boxes

Hi RuralGuy,

Yes there's the Q1 for the question that it's attached to. Basically I have attached it to the questions that are listed in the main table so that the individual scores (no matter what option box they click on) is registered in the table and the queries, etc can be written. It was the only way I could see how to get this to work.

So for option box 1 it's connected to Q1, option box 2 connected to Q2, etc up to Q23.

Very stuck now lol.

Thanks,

Donna x
 
I will assume Q1 is a field in a table. What is the datatype of the field? Is it an Integer numeric type? What values appear in the field when a selection is made in the OptionGroup?
 
I wish lol.

I'm kinda at a loss at what to do with it - I thought it might be just some sort of validation rule as VBA completely goes over my head.

I've put all the code in but everytime I try to test it it just keeps coming up with an error but it doesn't give me any direction or help - it highlights it but it's kind of being in a maze and not knowing which way to turn because it's not telling me anything other than 'your error is here but you've got to guess what it is' - sick of looking at this database and sick of the customer not knowing what they actually want!

Sorry to moan I'm really happy (sometimes). lol.

Donna x
 
Maybe if you could post a stripped down version of your db here, one of us could help out a bit more.
 
Attached Database

hi Guys,

I've attached the database (I hope), I've taken all the 'irrelevant' info.

Hopefully it makes sense to you all.

Thanks,

Donna x :confused:
 
Last edited:
Hi Donna,
Well at least now we can all understand why you were answering the questions in the manner you were. I'm amazed at how much you have been able to accomplish at the table level. It also explains why you have been struggling with the project. Here's a link to Duane Hookom's At Your Survey sample database. Duane has put together a very flexible survey system that demonstrates a different manner of table structures. If you could take a look at it and comment back in this thread, we can continue on from there.
 

Users who are viewing this thread

Back
Top Bottom