Solved Date Picker value depending on another control (1 Viewer)

mafhobb

Registered User.
Local time
Today, 04:58
Joined
Feb 28, 2006
Messages
1,245
Hi
I have a continuous subform where I enter reservations. In this subform, I have a textbox "CheckInDate" where I enter the start date for the reservation using the date picker. Just below I have another textbox "CheckOutDate" where I enter the ending date of the reservation also using the date picker.
Right now, when I click on the date picker, it always shows today's date. This is Ok for the CheckInDate field, but is there any way to show that check in date value in the "CheckOutDate" textbox when I click on its date picker? This would speed things up qute a bit when entering a new reservation's info. Keep in mind thst this is all on a continuous form.
Thanks
mafhobb
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:58
Joined
Sep 21, 2011
Messages
14,301
Just use DateAdd() to set the other textbox with the number of days being booked.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:58
Joined
May 7, 2009
Messages
19,243
but is there any way to show that check in date value in the "CheckOutDate" textbox
there is a way using VBA.
add code to CheckInDate Change Event:
Code:
Private Sub CheckInDate_Change()
Me.CheckOutDate = Me.CheckInDate.Text & ""
End Sub
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 10:58
Joined
Sep 21, 2011
Messages
14,301
there is a way using VBA.
add code to CheckInDate Change Event:
Code:
Private Sub CheckInDate_Change()
Me.ChecOutDate = Me.ChecInDate.Text & ""
End Sub
There should be a 'k' in there somewhere? :)
I only mention it, as so many people just copy without understanding the code. :(
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:58
Joined
May 7, 2009
Messages
19,243
already edited.
 

mafhobb

Registered User.
Local time
Today, 04:58
Joined
Feb 28, 2006
Messages
1,245
there is a way using VBA.
add code to CheckInDate Change Event:
Code:
Private Sub CheckInDate_Change()
Me.CheckOutDate = Me.CheckInDate.Text & ""
End Sub
Question: This will only affect the new record that is being entered, but not the other ones in the same continuous form, correct?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:58
Joined
May 7, 2009
Messages
19,243
You add a Check if you are in NewRecord, so the code will only run on New Record:

Private Sub CheckInDate_Change()
If Me.NewRecord Then
Me.CheckOutDate = Me.CheckInDate.Text & ""
End If
End Sub
 

Users who are viewing this thread

Top Bottom