The first problem I see is that your CkBox objects are not qualified. Should
be
Me.CkBox1. Then, what is Table.Field? Whatever it is, the syntax is
incorrect. If it is, as you describe it, a field in a table you are trying
to update, then there are some issues. First, is the Form bound or unbound?
If it is unbound, then you need to be sure Table is defined as a recordset
and that you have a current record in the table. I would recommend you use a
name other than Table, and the syntax should be:
Table![Field] = "Option 1"
Even then, I would not recommend you do it at that point. You should wait
until you are ready to update your record and assign all the field values at
one time:
With Table
.[Field] = "Option 1"
.[SomeOtherFields] = "whatever"
.Update
End With
If it is a bound form, then the code will not be the way to do it if the
check box is bound to the field. A better way is to create an invisible text
box control on your form, and bind the field to that. Then, in the After
Update event of the check box:
If Me.CktBox1 = True Then
Me.TxtBox1 = "Option 1"
End If
"AngelEyes" wrote:
> I have a form that I want to use to update information in a table. I've
> decided to use checkboxes to make it as simple and easy to use as possible. I
> want to use two of the checkboxes as an either/or kinda thing. Something like
> this:
> Private Sub CkBox1_Click( )
> If CkBox1.Value = True Then
> Table.Field = "Option 1"
> End If
> End Sub
> Private Sub CkBox2_Click( )
> If CkBox2.Value = True Then
> Table.Field = "Option 2"
> End If
> End Sub
> Only thing is I can't get it to work properly. I tried adding brackets, no
> brackets, quotes, no quotes. Any ideas?
>
>
|