Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862

    Found an issue with the code I provided!

    Here is the code in the DB. It really is the only thing being used, other than an unbound textbox. The purpose is to open a form or report to a specified date criteria. The catch is the time is stored in the table's date field along with the date becuase of the default value Now().



    The user inputs the desired date to apply to the Where critiria via an unbound textbox formated as Short Date to take advantage of the intrinsic date picker. The user then clicks a button. Begind the button is this code.

    Code:
    Dim dtReportStart As Date
    Dim dtReportEnd As Date
    dtReportStart = Me.txtDate.Value - 1
    dtReportEnd = Me.txtDate.Value + 1
    Dim strWhere As String
    strWhere = "[CNORepDate] BETWEEN #" & dtReportStart & "# AND #" & dtReportEnd & "#"
    DoCmd.OpenForm "frmA_A_Test", acNormal, , strWhere
    However, now that I paste the code here, I see that there is a major problem with the code. It will return three days instead of one. So the appropriate way is to convert the inoput from the user into a string and concatanate the time. The start time and end time need to include the seconds as well to insure no records are orphaned.

    Code:
    Dim strReportStart As String
    Dim strReportEnd As String
    strReportStart = Me.txtDate.Value & " 12:00:00 AM"
    strReportEnd = Me.txtDate.Value & "  11:59:59 PM"
    Dim strWhere As String
    strWhere = "[CNORepDate] BETWEEN #" & strReportStart & "# AND #" & strReportEnd & "#"
    DoCmd.OpenForm "frmA_A_Test", acNormal, , strWhere

  2. #17
    katmomo5 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    47
    Thank you!! I changed the date field default to date(), and it works now. I just have to add the print button Thank you so much!

  3. #18
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    If this thread is resolved, can you mark it so by using "Thread Tools" in the green bar towards the top?

  4. #19
    katmomo5 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    47
    Okay... I have questions about splitting the db, now.

  5. #20
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by katmomo5 View Post
    Okay... I have questions about splitting the db, now.
    I suggest starting a new thread. You can do a quick search on the topic to help you form your question and state the problems you face.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 11-23-2013, 09:00 AM
  2. Opening Report using WHERE CLAUSE not working
    By babui386 in forum Reports
    Replies: 2
    Last Post: 02-28-2013, 06:15 PM
  3. Replies: 3
    Last Post: 01-29-2013, 04:34 AM
  4. Replies: 1
    Last Post: 04-14-2012, 01:13 PM
  5. chr(13) & chr(10) not working in my report
    By RoosterD in forum Reports
    Replies: 5
    Last Post: 06-20-2011, 01:25 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