option group not registering selection

G

gsanderson99

I have a form with 12 option groups, each a field in a table. The
table formats each of the fields (Ambulation, Transfer, ADL, etc.) as
a number with a default of 0. The user selects an option, 1, 2, or 3,
via the option group. A command button runs this function:

Private Sub cmdCalculate_Click()
CountLow = 0
CountModerate = 0
CountComplex = 0
CountZero = 0

If Ambulation = 0 Then
CountZero = CountZero + 1
Else
If Ambulation = 1 Then
CountLow = CountLow + 1
Else
If Ambulation = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

If Transfer = 0 Then
CountZero = CountZero + 1
Else
If Transfer = 1 Then
CountLow = CountLow + 1
Else
If Transfer = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

If ADL = 0 Then
CountZero = CountZero + 1
Else
If ADL = 1 Then
CountLow = CountLow + 1
Else
If ADL = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

If Continence = 0 Then
CountZero = CountZero + 1
Else
If Continence = 1 Then
CountLow = CountLow + 1
Else
If Continence = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

If Nutrition = 0 Then
CountZero = CountZero + 1
Else
If Nutrition = 1 Then
CountLow = CountLow + 1
Else
If Nutrition = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

If Orientation = 0 Then
CountZero = CountZero + 1
Else
If Orientation = 1 Then
CountLow = CountLow + 1
Else
If Orientation = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

If Behavior = 0 Then
CountZero = CountZero + 1
Else
If Behavior = 1 Then
CountLow = CountLow + 1
Else
If Behavior = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

If SNF = 0 Then
CountZero = CountZero + 1
Else
If SNF = 1 Then
CountLow = CountLow + 1
Else
If SNF = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

If Admissions = 0 Then
CountZero = CountZero + 1
Else
If Admissions = 1 Then
CountLow = CountLow + 1
Else
If Admissions = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

If Evaluations = 0 Then
CountZero = CountZero + 1
Else
If Evaluations = 1 Then
CountLow = CountLow + 1
Else
If Evaluations = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

If Stability = 0 Then
CountZero = CountZero + 1
Else
If Stability = 1 Then
CountLow = CountLow + 1
Else
If Stability = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

If Treatment = 0 Then
CountZero = CountZero + 1
Else
If Treatment = 1 Then
CountLow = CountLow + 1
Else
If Treatment = 2 Then
CountModerate = CountModerate + 1
Else
CountComplex = CountComplex + 1
End If
End If
End If

'If CountZero = 0 Then
Me!Low_Acuity = CountLow
Me!Moderate_Acuity = CountModerate
Me!Complex_Acuity = CountComplex
Me!Zero_Acuity = CountZero
'Me!cmdCalculate.Visible = False
Me!cmdSave.Visible = True
Me!Tool_Complete = "Yes"
If CountComplex > 6 Then
Total_Acuity = "Complex"
boxComplex.Visible = True
lblComplexTotal.Visible = True
Else
If CountModerate > 4 And CountModerate < 7 Then
Total_Acuity = "Moderate"
boxModerate.Visible = True
lblModerateTotal.Visible = True
Else
Total_Acuity = "Low"
boxLow.Visible = True
lblLowTotal.Visible = True
End If
End If
cmdSave.SetFocus
'Else
'Message = MsgBox("Please fill in all prompts and Calculate
again", vbOKOnly, "Action not complete")
'optAmbulation.SetFocus
'End If

End Sub


I commented out the “If CountZero = 0” in order to determine where the
error is occurring. It is the “Orientation” option group that is not
registering the choice. The result remains the default, 0.

Also, can this be converted to a Select statemet?

Thank you,
Geoff
 
T

Tom Wickerath

Hi Geoff,
It is the "Orientation" option group that is not
registering the choice. The result remains the default, 0.

Check for a spelling typo, to see if you named the control "Orientation", or
perhaps accidently misspelled it as Oreintation. Also, do you have Option
Explicit as the second line of code in your module? If not, you should.

Always Use Option Explicit
http://www.access.qbuilt.com/html/gem_tips.html#VBEOptions

Does your code compile without any errors? While in the Visual Basic Editor
(VBE), click on:
Debug | Compile {ProjectName}

This option should become unavailable (grayed out) if your code is compiling
without an error.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 
G

gsanderson99

Tom,

Thank you for the reply. I added Option Explicit to the code and
followed the advice of the link you attached for future use.

The spelling is correct in the table, form, and code. I compiled the
code with no errors. I deleted the problem option group and re-entered
it onto the form, but the result was the same. Additionally, I deleted
Orientation from the table and re-entered it and still have the same
problem. I deleted the If Then statement and re-typed it, but again,
same result. I'm not an expert, so I'm probably overlooking something,
but I can't seem to find it.

Geoff
 
B

Bob Quintal

m:
Tom,

Thank you for the reply. I added Option Explicit to the code and
followed the advice of the link you attached for future use.

The spelling is correct in the table, form, and code. I compiled
the code with no errors. I deleted the problem option group and
re-entered it onto the form, but the result was the same.
Additionally, I deleted Orientation from the table and re-entered
it and still have the same problem. I deleted the If Then
statement and re-typed it, but again, same result. I'm not an
expert, so I'm probably overlooking something, but I can't seem to
find it.

Geoff

Check that the Orientation field in the table is an Integer or Long
type of Number. If it's any other, you may get some problems.

You may find that your code would be much faster if you changed the If
Then Else statements to Select Case Statements:

Select Case Orientation
Case 0
CountZero = CountZero + 1
Case 1
CountLow = CountLow + 1
Case 2
CountModerate = CountModerate + 1
Case Else
CountComplex = CountComplex + 1
End Select
 
G

gsanderson99

Check that the Orientation field in the table is an Integer or Long  
type of Number. If it's any other, you may get some problems.

You may find that your code would be much faster if you changed the If
Then Else statements to Select Case Statements:

Select Case Orientation
Case 0
  CountZero = CountZero + 1
Case 1
  CountLow = CountLow + 1
Case 2
  CountModerate = CountModerate + 1
Case Else
  CountComplex = CountComplex + 1
End Select

Bob,

Thanks for the help with the Select Case statement. I had tried
something similar but it didn't work. This one does work, except for
Orientation again. I even tried changing the default value from 0 to
1, and 0 to 2, but the option group still read the result as 0, no
matter what I selected. Any ideas why?

Geoff
 
B

Bob Quintal

m:
Bob,

Thanks for the help with the Select Case statement. I had tried
something similar but it didn't work. This one does work, except
for Orientation again. I even tried changing the default value
from 0 to 1, and 0 to 2, but the option group still read the
result as 0, no matter what I selected. Any ideas why?

Geoff
Check the TABLE design. Make sure that Orientation Field Has Number
as the Field Type, and Integer or Long Integer as field size.
 
G

gsanderson99

m:







Check the TABLE design. Make sure that Orientation Field Has Number
as the Field Type, and Integer or Long Integer as field size.

--
Bob Quintal

PA is y I've altered my email address.- Hide quoted text -

- Show quoted text -

Orientation is indeed a Number with field type Long Integer.
Interesting new development...I decided to rename Orientation to Dave
and changed the objects connected to the field. I ran my Calculate
function and received an unknown variable error for Dave in the Select
Case statement. Where did Access get the idea that Dave was a variable
when it is a valid field name?

Geoff
 
B

Bob Quintal

m:

Orientation is indeed a Number with field type Long Integer.
Interesting new development...I decided to rename Orientation to
Dave and changed the objects connected to the field. I ran my
Calculate function and received an unknown variable error for Dave
in the Select Case statement. Where did Access get the idea that
Dave was a variable when it is a valid field name?

Geoff

In visual basic code, Access hiearchically treats variables, bound
controls and field names like all were variables. especially if you
create a bound control with the same name as the field.

When you say Dave, it looks for the field name, does not find it,
looks for a control, does not find it, looks for a variable, does not
find it and reports the error you get.

The me! and me. prefixes can sometimes be used to differentiate
between the control and the field name.

Is it possible that your form's record source is not the table, but a
query? if you changed the table field name, but did not update the
query, that could cause your problem

Did you change the option group to bind to thed renamed field?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top