Alienware 17 R4 2017 review
Hi, I have the code below to send data based on whether optionbutton and
checkboxes were ticked or not to an access database.
Now I can get the code to work fine, but what I wanted to do was have a for
loop that tested each checkbox or optionbutton and then send the data
instead of having to write the code for every checkbox and optionbutton. To
do this, I am holding the fieldname from access in the tag property of the
optionbutton and checkbox.
For some reason, when the code gets to
vRecordSet!xArray(xCount).Tag = "Selected" it fails as it says it
can't find the field in the database. I have put a msgbox in front of this
line to test that it is pulling the tag property correctly and it is.
So what I am expecting in laymens terms is... If the tag proprty holds the
value 'csrName', then the code would become:
vRecordSet!csrName = "Selected"
As I say, if I actually code it with vRecordSet!csrName = "Selected"
Hope that makes sense.
Dim xCount As Integer
Dim xControl As Control
Dim vConnection As New ADODB.Connection
Dim vRecordSet As New ADODB.Recordset
vConnection.connectionstring = "C:\mi.mdb" &
vRecordSet.Open "miTable", vConnection, adOpenKeyset, adLockOptimistic
For Each xControl In myForm.Controls
If TypeOf xControl Is MSForms.CheckBox Or TypeOf xControl Is
ReDim Preserve xArray(xCount)
Set xArray(xCount) = xControl
xCount = xCount + 1
For xCount = 0 To UBound(xArray)
If xArray(xCount) = True Then
vRecordSet!xArray(xCount).Tag = "Selected"
vRecordSet!xArray(xCount).Tag = "."
Set vRecordSet = Nothing
Set vConnection = Nothing
This thread is now locked and can not be replied to.