Set default date on DatePicker from a drop down control event

%3CLINGO-SUB%20id%3D%22lingo-sub-3506785%22%20slang%3D%22en-US%22%3ESet%20default%20date%20on%20DatePicker%20from%20a%20drop%20down%20control%20event%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3506785%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20it%20possible%20to%20have%20the%20default%20date%20of%20a%20date%20picker%20control%20be%20programmatically%20set%20when%20a%20user%20clicks%20a%20drop%20down%3F%20I%20have%20two%20controls%2C%20DropDown1%20and%20DatePicker%201.%20What%20I%20would%20like%2C%20is%20when%20the%20user%20clicks%20the%20DropDown1%2C%20the%20default%20date%20of%20DatePicker1%20changes%20to%2010%20days%20from%20today's%20date.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETIA%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETom%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3506785%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerApps%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3509016%22%20slang%3D%22en-US%22%3ERe%3A%20Set%20default%20date%20on%20DatePicker%20from%20a%20drop%20down%20control%20event%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3509016%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F415657%22%20target%3D%22_blank%22%3E%40TRundle2022%3C%2FA%3E%26nbsp%3Byes%20you%20can%20set%20the%20DefaultDate%20property%20to%20change%20based%20on%20the%20selection%20in%20the%20dropdown.%20Make%20sure%20you%20have%20set%20the%20first%20item%20in%20the%20dropdown%20to%20%22%22%20then%20set%20the%20DefaultDate%20property%20of%20the%20date%20picker%20to%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23DF0000%22%3EIf(Dropdown1.Selected.Value%20%26lt%3B%26gt%3B%20%22%22%2CToday()%2B10%2CToday())%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23000000%22%3EOr%20you%20can%20do%20something%20like%20this%20to%20set%20it%20to%20a%20date%20based%20on%20which%20item%20in%20the%20dropdown%20has%20been%20selected%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23DF0000%22%3EIf(Dropdown1.Selected.Value%20%3D%22Anguilla%22%2CToday()%2B10%2CIf(Dropdown1.Selected.Value%3D%20%22Antigua%22%2CToday()%2B20%2C%20Today()%2B30))%3C%2FFONT%3E%3CBR%20%2F%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23000000%22%3E%3CFONT%20color%3D%22%23DF0000%22%3E%3CFONT%20color%3D%22%23000000%22%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23006400%22%3EIntranet%2C%20SharePoint%20and%20Power%20Platform%20Manager%20(and%20classic%201967%20Morris%20Traveller%20driver)%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Is it possible to have the default date of a date picker control be programmatically set when a user clicks a drop down? I have two controls, DropDown1 and DatePicker 1. What I would like, is when the user clicks the DropDown1, the default date of DatePicker1 changes to 10 days from today's date.

 

TIA,

 

Tom

1 Reply

@TRundle2022 yes you can set the DefaultDate property to change based on the selection in the dropdown. Make sure you have set the first item in the dropdown to "" then set the DefaultDate property of the date picker to:

If(Dropdown1.Selected.Value <> "",Today()+10,Today())

 

Or you can do something like this to set it to a date based on which item in the dropdown has been selected:

If(Dropdown1.Selected.Value ="Anguilla",Today()+10,If(Dropdown1.Selected.Value= "Antigua",Today()+20, Today()+30))

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)