简体   繁体   中英

ms access: how to display the invisible object in form when load the form?

Currently I had set CAS_No2, CAS_No3, CAS_No5 and CAS_No6 as not visible in property sheet. Once User choose "Blend" or "Master Batch", it will visible.

It do work out. But, when I close the form and reopen it back, CAS_No2, CAS_No3, CAS_No5 and CAS_No6 not appear. I've pun this code under 'Form_Load()' and 'Form_Current()' but it still not appear even there are value in it. It will only appear when I click back Type combo box and choose "Blend" or "Master Batch".

I want the data appear when Type's default data is "Blend" or "Master Batch".

Private Sub Type_Click()
If Me.Type.Value = "Blend" Or Me.Type.Value = "Master Batch" Then
    Me.CAS_No2.Visible = True
    Me.CAS_No3.Visible = True
    Me.Dosage5.Visible = True
    Me.Dosage6.Visible = True
Else
    Me.CAS_No2.Visible = False
    Me.CAS_No3.Visible = False
    Me.Dosage5.Visible = False
    Me.Dosage6.Visible = False
End If
End Sub   

Question. Is Me.Type bound to the database?. It will not have the correct value until the Current event, so you need that code in the Current event on the form. If its not bound to the database I would still put the code on the Current. What is the default value for Me.Type?

You also need it on the "Change" event of Type (assuming its a combo box). Putting it on the click event will read the old value, before you change it. This is because you generally click on a combo box first and then select a new value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM