By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,826 Members | 2,384 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,826 IT Pros & Developers. It's quick & easy.

Validating Check Boxes in relation to Option Group input

P: 4

I am trying to do a fairly simple validation, but it just won't work! I have 14 module options (split into 2 categories-semester 1 and semester 2) and I am attempting to ensure that one option per category is checked in relation to chosen course title. I have tried all sorts of IF and Case statements- i don't get any error message but it just doesn't work the way I want it to. With the code the way it is at the moment, Valid8 always appears to be false. Here's my code:
Expand|Select|Wrap|Line Numbers
  1. Core1 = Sem1Op7 + Sem2Op7
  2. Core2 = Sem1Op5 + Sem2Op6
  3. Core3 = Sem1Op6 + Sem2Op5
  4. Course = DLookup("[CourseTitle]", "Student", "[CourseTitle] = Forms!Student!Frame10")
  7. If (Core1 = -2) And (Course = "1") Then
  8.     Valid8 = True
  9. ElseIf (Core2 = -2) And (Course = "2") Then
  10.     Valid9 = True
  11. ElseIf (Core3 = -2) And (Course = "3") Then
  12.     Valid10 = True
  13. End If
I would like a different msgbox to come up for each valid 8/9/10

Any help would be very much appreciated-I bet it is a silly mistake

Jan 7 '10 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 15k+
P: 31,489
Sophie, you haven't really explained what the controls are on your form that you're working with.

Furthermore, if you choose to work with generic, Access assigned, names (EG. Frame10) then no-one will have much idea what it is unless you explain it separately. It's generally easier to give things meaningful names though.

I'm thinking you're probably looking for Radio Buttons in an Option Group, but though you refer to the OG in the title, there is nothing to indicate what you are working with here.

Lastly, the context of your code (procedure specification etc) is often more important (and tells a reader more) than the code itself. It's rarely a good idea to leave it out.

We can at least determine that you have a table named [Student] and a form named [Student] which has a frame (called Frame10). The other controls on the form are named (which is good) but the names (and explanation) omits the types of any of these controls (conventionally a name would have a 3-letter prefix indicating the type - txtBob for TextBox; lstGerry for a ListBox; chkMarkus for a CheckBos etc).
Jan 7 '10 #2

P: 4
Sorry I didn't explain myself very clearly, I was trying to find the best way to explain myself concisely, but it backfired. so...
I have a form named [Student], on this form I have an option group which captures the [Course Title] data (this is what is named frame10). I then have 7 option buttons which capture Semester 1 module options data, and a further 7 option buttons which capture Semester 2 module options data. These are named [Sem1Op1], [Sem1Op2] and so on.

My aim with the code:
When the student chooses their [Course Title] they must also have chosen two specific module options eg. Sem1Op5 and Sem2Op6

I hope this makes the scenario clearer

Thanks for your patience
Jan 8 '10 #3

Expert Mod 15k+
P: 31,489
Sophie, I'm afraid I looked at your latest post earlier and it seemed to be a much better explanation. I decided I neeeded to put it aside until I had a little time to get to grips with it though. Now I have the time I find that it isn't as clear as I'd thought it was. Let me comment on some of the places where I get confused and I'm sure we can get to the heart of the matter.
  • I can't imagine what a field [CourseTitle] type might be if it's not text. It doesn't seem to be text as you are trying to filter on it without any quotes (See Quotes (') and Double-Quotes (") - Where and When to use them). You also seem to feel the value is contained within an OptionBox or Frame control. This type of control can only contain numeric values which reflect which of the (typically) RadioButton controls is selected.
  • Your explanation mentions 7 options per semester, but your code only has three each.
  • The code that references the options uses arithmetic on bBoolean values. This is fine if done with full understanding, yet can be complicated for those who don't appreciate it well. From my position, I have to question whether your grasp is strong enough for me to rely on what the code says, particularly as it doesn't seem to match your explanation very well. That leaves me struggling to understand where you want me to take you.
  • The context, as mentioned before, is still missing. With a perfect explanation this is not necessary, but in this situation it may provide clues to me as to what you are actually trying to communicate. If you look back to the first point I make for instance, the Dim statement for the variable Course would have given me a better understanding of what you were thinking when you wrote this code.
Sorry for the delay in responding, I honestly was convinced before I looked into it that it would be straightforward when I got around to it. Unfortunately it wasn't, which was my bad call.
Jan 10 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.