Link to home
Start Free TrialLog in
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
    Else
        litCalendario01.Visible = False
    End If
End Sub

Open in new window

My idea is to hide litCalendario01 if it's not selected
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

ASKER

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'?
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
    Else
        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
                .fSetUp
                .Caption = "Prossima Udienza"
            End With
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Fabrice Lambert
Fabrice Lambert
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial