Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This should be easy, but it's not working?? 1

Status
Not open for further replies.

Turb

Technical User
Feb 11, 2003
154
US
Hi All!
I know this should be easy and I've searched the forums and FAQ to try different configurations, but I cannot get this to work on my Access 2003 form.
Please tell me what I'm doing wrong.

I'm trying to auto-check a check box based on a selection chosen in a combo box.

On my form, I have a combo box (cboCycle) that is based on a table (Cycle_tbl). My check box is (ARR_MCABOPT1).

The table (Cycle_tbl) is small and only consists of two columns (ID and cycle) and two records (ID "1" - cycle "60Hz", ID "2" - cycle "50Hz").

Properties of combo box cboCycle are:
Row Source = Cycle_tbl
Column Count = 2
Bound Column = 2

I placed this as an 'After Update" event on the combo box (cboCycle):
Code:
Private Sub cboCycle_AfterUpdate()

   If Me.cboCycle.Column(2) = "50Hz" Then
      Me.ARR_MCABOPT1.Value = True
   Else
      'Do Nothing
   End If
    
End Sub


I've tried changing the cboCycle.Column to (1) and even (0).
I've tried changing the If statement to read Me.cboCycle.Column(2) <> "60Hz" and when that didn't work, again played with the column number.
Still no dice.

Help please!


- Turb
 
how are ya Turb . . .

Note: [blue]Column Index[/blue] starts at zero (0). If you combo comprises both fields, in the left to right order of ID, Cycle, then your after column 1.

So far the only thing wrong I see is you don't set [blue]ARR_MCABOPT1[/blue] false when 60hz is chosen. try the following instead:
Code:
[blue]Private Sub cboCycle_AfterUpdate()
   
   Me!ARR_MCABOPT1 = (Me!cboCycle.Column(1) = "50Hz")
    
End Sub[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Ace,
Hey thanks!
Worked like a charm.

Pink one for ya'!



- Turb
 
Turb . . .

In your origional code you just needed to set [blue]ARR_MCABOPT1[/blue] to false:
Code:
[blue]   Else
      Me.ARR_MCABOPT1 = False
   End If[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Ace,
This may seem strange, and I know you say my code works if I add the Me.ARR_MCABOPT1 = False but,
my code:
Code:
   If Me.cboCycle.Column(1) = "50Hz" Then
      Me.ARR_MCABOPT1.Value = True
   Else
      Me.ARR_MCABOPT1 = False
   End If
doesn't work on this form (doesn't check the checkbox), but yours does.
Anyway, I just appreciate the help! [2thumbsup]

Do you know if this same type of code should work on a form based on a query (if the Cycle value is already populated, and then changed using a CBO)?
It doesn't seem to...


- Turb
 
Whoops!
Found the problem.
This:
Code:
   If Me.cboCycle.Column(1) = "50Hz" Then
      Me.ARR_MCABOPT1.Value = True
   Else
      Me.ARR_MCABOPT1 = False
   End If
Should be this:
Code:
   If Me[b][COLOR=red]![/color][/b]cboCycle.Column(1) = "50Hz" Then
      Me[b][COLOR=red]![/color][/b]ARR_MCABOPT1.Value = True
   Else
      Me[b][COLOR=red]![/color][/b]ARR_MCABOPT1 = False
   End If

Thanks Ace!


- Turb
 
Turb . . .

[blue]Poetry In Motion![/blue] [thumbsup2]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top