Using a checkbox to update a field (1 Viewer)

liquidzoo

Registered User.
Local time
Today, 04:24
Joined
May 22, 2008
Messages
11
I have a form designed, and so far everything is working perfectly, except for being able to update the checkboxes from whatever state they were in to begin with.

When I click on a checkbox, I want it to update a certain field in the table with an x if it's True, or nothing if it's False (checked or unchecked).

This is the code I've been using, but it's giving me an error.

Private Sub chk_Mem_Click()
If chk_Mem = True Then
Set Combo1.Column(3) = "x"
i = 1
Else
Set Combo1.Column(3) = ""
i = -1
End If
Set Combo1.Column(8) = Combo1.Column(8) + i
txtHol = Combo1.Column(8)
End Sub

Can anyone help me out?
 
2 things -

1. Use the checkbox's after update event instead of the click event.

2. You have to set the combo's value to whatever the bound field is. You cannot just choose a column.
 
In the Row Source for the Combo, the column numbers listed are defined and used. Another macro I have for the Combo itself works when using the column numbers, but I am certainly willing to rework my code so that it works correctly.

The checkbox itself is not bound to a field on my table, perhaps that is where my error lies.
 
No, I don't think you understand. A combo has ONE bound column(not talking about bound to a field in the table on the form). It is the field that returns the value of the combo box. Yes, you can GET the value of any column in the combo box, but you can only SET the value of the column that is set as the bound column.
 
I see.

So, with my other macro that I have written, it is possible to read any value from the table that is sourced in the combo, which I have done; but the code to actually write data into my table won't work the same way.

So what I need to do is find a way to reference that particular column, using whatever data is in my combo box at the time as the row to look at, and depending on the state of the checkbox write or clear data from that particular field.

I will keep digging, thank you for your input. I did not realize that retrieving data and writing data from a form functioned differently in this particular aspect.
 
You probably can use a DLOOKUP to get the key value to set the combo box to based on the value you have for a particular column.
 

Users who are viewing this thread

Back
Top Bottom