mardi 5 mars 2019

Checking and Unchecking Checkboxes in Access

I have a form in MS Access with multiple checkboxes which I want to use to fill up one textbox. If one of the checkboxes gets unchecked, I want its value be deleted from the textbox without deleting other values. I'm new at using Access and all the coding in VBA (been reading ebooks for the past 3 weeks) and although I've tried to do research online it's been difficult for me to find the right code.

This is what I have so far:


First code found

Private Sub cb_click()
If Me.cb1 = True Then
Me.txtComentarios.Value = "INACTIVO;"
Else
Me.txtComentarios.Value = Null
End If

End Sub


Second code found

Private Sub cb2_Click()
If Me.cb2 = -1 Then
Me.[txtComentarios] = [txtComentarios] & "DISCREPANCIA"
Else
Me.[txtComentarios] = ""
End If
Exit Sub

End Sub

Also I would like for the checkboxes to fill the textbox in the same order the chechboxes are displayed.

Ex.

cb1; cb2; cb3

If, cb2 gets unchecked and its value gets deleted, I should have "cb1; cb3" but if I re-check cb2 I should get "cb1; cb2; cb3" again.

I just hope someone could guide me in. Thank you in advance.

Luz




Aucun commentaire:

Enregistrer un commentaire