Results 1 to 6 of 6
  1. #1
    paultje_bos is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2016
    Posts
    13

    Textbox with date input answers #Name?

    Hi,



    I have a form where I have 2 textboxes with dates, FROM_DATE and TO_DATE (this is the base for some queries). In the 2 textboxes I selected SHORT_DATE as format and I created an default value that gives me the in the FROM_DATE the first date of last month and in TO_DATE the last date of last month. This is done by an third (non visible) textbox that select the date of today minus one month, below the expressions.

    LAST_MONTH: Control source: =DateAdd("m",-1,Date())
    FROM_DATE: Default Value: =DateSerial(Year([LAST_MONTH]),Month([LAST_MONTH]),1)
    TO_DATE: Default Value: =DateSerial(Year([LAST_MONTH]),Month([LAST_MONTH])+1,0)

    I use this trick already for a long time, never fails...untill now. I have one particular form where I get in the FROM_DATE and TO_DATE #NAME? as result. No matter what I try (like changing format, changing date setting, changing ) it won't change.
    When I completely remove it, create them again, it works, untill I close the database, reopen it and it's back again. The weird thing is, I have an older copy of the same database, and there it works perfectly. So I am completely out of solutions.

    Also, the LAST_MONTH box doesn't have the problem!

    Anybody have an idea what this is causing?

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Date serial is an Excel function and is not used in Access.
    Dates are already in date format. If you need to add/subtract dates, use DateAdd().

  3. #3
    paultje_bos is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2016
    Posts
    13
    I am sorry Ranman, I don't follow you. What do you mean DateSerial is an Excel function? It is available in Access right, so why can't I use it? Maybe I didn't explain my problem clearly enough, because I don't want to add or subtract dates, I just want to display 2 dates in 2 texboxes, one is the first day of last month, one is the last day of last month.

    Like I said, the method works, but not in my current project.

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    When I completely remove it, create them again, it works, untill I close the database, reopen it and it's back again
    So if you set your form to not allow design changes, or when you close it don't save changes?

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Does the record source table or query for the form that is causing the problem have a field called [Last_Month] in it? If so, that may the issue - Access is confused between the record source field and the control called [Last_month].

  6. #6
    paultje_bos is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2016
    Posts
    13
    Your comment Aytee reminded me something, I compared the Form settings with the old version and apparently I had a module on the current form (not doing anything) causing this problem, I removed it and now it works. Very weird (for me, but it probably has a reason causing this error).

    At least thanks for you guys to think with me!

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

Similar Threads

  1. New Textbox control won't accept input
    By sprtrmp in forum Forms
    Replies: 18
    Last Post: 06-02-2016, 06:02 AM
  2. Replies: 7
    Last Post: 01-02-2016, 09:49 AM
  3. Replies: 3
    Last Post: 09-20-2011, 11:54 AM
  4. Input Value based on another textbox value
    By dude19 in forum Access
    Replies: 2
    Last Post: 06-30-2011, 03:48 PM
  5. Textbox will not allow input
    By cwf in forum Forms
    Replies: 0
    Last Post: 04-04-2008, 04:08 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