Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2022
    Posts
    21

    Exclamation Getting date from form causes error?

    Morning all,

    I have a problem where access is getting an error pulling a date from a form. Seems like everything is ok from what I can see, where it's pulling from the table it has the date and time e.g. 3/15/2022 5:35AM, but I just want to pull the date...... any thoughts?

    Attachment 47540
    Attachment 47541
    Attachment 47542
    Here is the code:
    Code:
    PARAMETERS [Forms]![formChartByName]![Combo1] Text ( 255 ), [Forms]![formChartByName]![Text3] DateTime;
    TRANSFORM Count(*) AS [Count]
    SELECT tablemyTimeKeeper.myName
    FROM tablemyTimeKeeper
    WHERE (((tablemyTimeKeeper.myName)=[Forms]![formChartByName]![Combo1]) AND ((tablemyTimeKeeper.myDateTime)=[Forms]![formChartByName]![Text3]))
    GROUP BY tablemyTimeKeeper.myName
    PIVOT IIf(InStr([myBarcode],"Indirect")>0,"Indirect","Order");


  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Use DateValue() on the field ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    What data types are in the controls? I see no delimiters, so only numbers would be appropriate? Strings would have to be delimited with ' , dates with #
    e.g.
    tablemyTimeKeeper.myName) = '" & [Forms]![formChartByName]![Combo1]) & "' AND...

    As written, you're literally passing "[Forms]![formChartByName]![Combo1]" - not what the control contains. Unless I'm wrong and setting the parameter would over-ride that. I'd be surprised if that were the case.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Join Date
    Mar 2022
    Posts
    21
    Hey,

    @Welsh - I tried that and it returns a blank query
    @Micron - The date is a textbox set as short date, the combo box I set to Bound Column 1 in properties...

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Well I would start simple, get the source data working first, THEN start with PIVOT etc.

    Failing that, upload the DB with enough to be able to replicate the problem.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Then try date delimiters instead of text? I agree - to be sure it's not the pivot part that's at fault, just get the select part working from SELECT to WHERE.
    Is that sql in a code procedure or a stored query? I'm guessing query because that's the forum you posted in. So, if you try to switch from sql view to datasheet view and it balks, does Access highlight in sql view what it thinks is the offending part?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Join Date
    Mar 2022
    Posts
    21
    Hey all,

    @Welsh - Yeah I am trying everything to my knowledge and your suggestions, very wild how this is acting.
    @Micron - It's a query, even trying switching views results in same error.

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

Similar Threads

  1. Replies: 7
    Last Post: 04-30-2018, 12:32 PM
  2. Replies: 11
    Last Post: 06-28-2015, 06:42 PM
  3. Replies: 4
    Last Post: 04-21-2015, 07:12 PM
  4. Replies: 1
    Last Post: 12-12-2011, 06:32 AM
  5. Date error on my forms
    By elbob62 in forum Access
    Replies: 1
    Last Post: 12-05-2008, 05:35 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