Jumat, 24 Mei 2019

[MS_AccessPros] Re: Visible or not

 

Bill - Changing a property via code is only temporary. If the form is closed the change is dismissed. If you are storing the selection in a table you could use DLookup() during the form's Load event to recall that value and hide or expose the control just like you do in the AfterUpdate event.


If DLookup("myfield", "myTable", "WHERE contitionGoesHere") = 1 Then...

Shorter way to write your code:

Private Sub cboOtherCoverage_AfterUpdate()

Me.HelNameOfOtherCoverage.Visible = (cboOtherCoverage = 1)
 
End Sub

-Bill Moscfa


---In MS_Access_Professionals@yahoogroups.com, <Bill.Singer@at-group.net> wrote :

I have a combo box in which the user selects and options.  Depending on the option, additional fields show up on the form.  The combo box stores a value in a table, which is used later in a report.  The code is below. It works fine during the initial form completion.  However if I close the form and reopen it, the correct field do not show up.  Do I have to also put this code in the From "On Current Event"?   What if I have a few of these on one form, do I have to put code for all of them in the form "On Current" event?

 

Here is the code.

 

Private Sub cboOtherCoverage_AfterUpdate()

 

If cboOtherCoverage = 1 Then

Me.HelNameOfOtherCoverage.Visible = True

 

Else: Me.HelNameOfOtherCoverage.Visible = False

End If

 

End Sub

 

 

Bill

 

Bill Singer

Access 365

Minnesota

__._,_.___

Posted by: wrmosca@comcast.net
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

SPONSORED LINKS
.

__,_._,___

Tidak ada komentar:

Posting Komentar