Avatar of Giulio Benvenuti
Giulio BenvenutiFlag for Italy

asked on 

if it is selected then ...

Hello. This is the code i would like use for access, but it doesnt work. Whats wrong?
Private Sub txtDataProssimaUdienza_LostFocus()
    If litCalendario01 is selected Then
        litCalendario01.Visible = True
        litCalendario01.Visible = False
    End If
End Sub

Open in new window

My idea is to hide litCalendario01 if it's not selected
VBAMicrosoft Access

Avatar of undefined
Last Comment
Fabrice Lambert
Avatar of Daniel Pineault
Daniel Pineault

What is litCalendario01?  A Control, which type of control exactly (button, checkbox, ...)?  Please explain further.
Avatar of Giulio Benvenuti


it's a button
In that case what "is selected" represent for you?  You could use multiple button events:On Click, On Got Focus, ... it truly depends what you want to happen and when.  Please explain the user experience you are trying to achieve here.

I don't understand your code as you seem to be hiding the control if it is 'selected'?
Avatar of Giulio Benvenuti


there are a txtbox i called "txtDataProssimaUdienza" (its a date type, but i disabled the calendar because i needed to disable Saturday and Sunday)  and a button i called "litCalendario01" (the calendar connected to txtDataProssimaUdienza).
litCalendar01 isn't visible untill i get focus on txtDataProssima. When i lose focus on txtDataProssimaUdienza litCalendar01 isn't visible, but i can't click on it to open the calendar.
This is the code for txtDataProssimaUdienza
Private Sub txtDataProssimaUdienza_GotFocus()
    litCalendario01.Visible = True
End Sub

Private Sub txtDataProssimaUdienza_LostFocus()
    If litCalendario01 Then
        litCalendario01.Visible = True
        litCalendario01.Visible = False
    End If
End Sub

Open in new window

and this is the code for litCalendar01
Private Sub litCalendario01_Click()
    Dim strFrmName As String
    strFrmName = "DatePickerCalendar"
        DoCmd.OpenForm strFrmName
            With Forms(strFrmName)
                Set .prpCtrlInitialDate = Me.txtDataProssimaUdienza
                .Caption = "Prossima Udienza"
            End With
End Sub

Open in new window

Avatar of Fabrice Lambert
Fabrice Lambert
Flag of France image

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews


IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo