Results 1 to 8 of 8
  1. #1
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481

    Year Start & End Date after Selecting Year from Cbo Box.

    Hi

    I have form which contains the fields of SchYear (Combo Box), StartDate & EndDate fields.

    I want to auto fill up the startDate & EndDate by selecting the year from ComboBox.

    If select 2018


    StartDate: 01/01/2018
    EndDate: 31/12/2018

    I have the below code for defaults values as for current year but how to guide the date fields according to the combo box?
    DateSerial(Year(Date()),1,1)
    DateSerial(Year(Date()),12,31)

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Just replace Date() with Me.comboboxname (modify as appropriate) assuming the date field is the bound column
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Join Date
    Apr 2017
    Posts
    1,673
    Quote Originally Posted by ridders52 View Post
    Just replace Date() with Me.comboboxname (modify as appropriate) assuming the date field is the bound column
    Not Date(), but Year(Date())

  4. #4
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Hi

    Thanks for input. The name of the combo box is "CboYear"
    You mean to put the default value as =DateSerial(Me.CboYear,1,1)

    But its showing Type? Error.

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Does the combo box have values like 2018 or full dates like 03/10/2018?
    If the first of these then your formula should work.
    If its a full date, as I originally assumed, then what I wrote previously was correct
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    Join Date
    Apr 2017
    Posts
    1,673
    When your combo has multi-column Row Source property, the Bound Column property of combo defines the column which returns the value for Me.CboYear. It may be different from value you see in form!

  7. #7
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Hi

    The combo is fed from value list values like 2018/2019/2020.

    but does not work

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Yes but is that the first column and is it the bound column?

    when you say it does not work, what exactly happens?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-16-2016, 05:02 PM
  2. criteria with start date as month and year
    By louise in forum Queries
    Replies: 3
    Last Post: 12-18-2015, 11:10 AM
  3. Selecting Year to date
    By lugnutmonkey in forum Queries
    Replies: 3
    Last Post: 01-15-2013, 08:48 AM
  4. Replies: 11
    Last Post: 08-04-2010, 04:26 PM
  5. Replies: 1
    Last Post: 12-09-2005, 10:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums