mardi 28 janvier 2020

Getting MS-Access form to save invisible combo boxes as a null or 0 value in query and table

I don't know that how I have built my form is necessarily the best way that I can do it, but it was the way that I could get it to work, at least partially. I have built a form in ms-access 2007 that uses vba to either hide or make available certain combo boxes. The first choice and the one on which the rest of the form is based is a yes/no option, being that either the customer requires outside services for their job or not. Once that is selected the user can then choose from the outside service options(Which are the combo boxes, either visible or no based on the first choice). So this is where the problem comes in, I have code written so that if the user chooses no in the very first box the rest of the boxes are made invisible. However if the user chooses yes they must then choose values, again yes or no to either retain or remove other options for the remainder of the form. What I am looking to do is to make it so that when the user returns to the form what choices they made are still there. So if they chose no then the form would basically be blank and if they had said yes initially than that answer along with only the other choices they made would be available.

What I am currently using is a simple if-then statement to make the boxes either visible or not.

Private Sub Combo36_AfterUpdate()
    If Combo36.Value = "No" Then Me.Combo18.Visible = Flase
    If Combo36.Value = "Yes" Then Me.Combo18.Visible = True
    If Combo36.Value = "No" Then Me.Combo20.Visible = Flase
    If Combo36.Value = "Yes" Then Me.Combo20.Visible = True
End Sub

Obviously I am not experienced with access and have stumbling my way through it. I am sorry if any of what I have said above is confusing. If clarity is needed please let me know.

Aucun commentaire:

Enregistrer un commentaire