Re: datetimepicker question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I'm using a datetimepicker control, I want the user to pick a month/year
using the control. The actual day of the month they pick is of no value.

What I want to do is to get the first day of the month and the last day of
the month of the month they select.

Any idea of how I can grab these two dates?

First off, if you don't care about the actual day, why show the user a
monthly calendar display that requires him/her to select a day? Why not just
use a ComboBox for the months and, depending on the range of years allowed,
either a ComboBox or TextBox for inputting the year value?

Anyway, to answer your question, use the CloseUp event to reset the value
picked by the user to the one you want. Use either this...

' Set first day of month
With DTPicker1
.Value = DateSerial(.Year, .Month, 1)
End With

or this...

' Set last day of month
Private Sub DTPicker1_CloseUp()
With DTPicker1
.Value = DateSerial(.Year, .Month + 1, 0)
End With

depending on what you want your user to see.

Rick


.



Relevant Pages

  • Re: prevent the user to open the list of the combo-box
    ... depending on the value of the main form ... control, so the combobox is simply inaccessible in the circumstances you ... Liat wrote: ...
    (microsoft.public.access.forms)
  • choos one of two comboboxes
    ... the second one lists the customer advisor ... Depending on which combobox the user selects, i want to use the value the ...
    (microsoft.public.excel.programming)
  • Combobox
    ... I have a custom control derived from ComboBox that I need to load itself depending on one of its parameter. ... It doesn't seem to have a "OnLoad" event... ...
    (microsoft.public.dotnet.languages.csharp)
  • Different tables as combobox RowSource in a form
    ... I need for the RowSource of a combobox on a form to be one ... of two tables depending on the information in a different ... If Forms!frmAllPts!= "Fistula" Then ...
    (microsoft.public.access.formscoding)