Results 1 to 7 of 7
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    docmd.open form between dates condition

    I have



    Code:
    DoCmd.OpenForm "frmPaymentsUncompleted", , , "[BookingDate]= between me.txtBeforeDate and me.txtUntilDate"
    The form has to unbound text boxes formatted as short date, before and one until - and a button that opens the form to whatever those date values entered are.

    I am unsure of how to put in the correct code to make the form work....

    frmPaymentsSearchDate is the name of the form that searches the dates.

    maybe ?

    Code:
    DoCmd.OpenForm "frmPaymentsUncompleted", , , "BookingDate=" > Me.txtBeforeDate and < me.txtUntilDate
    help..

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    DoCmd.OpenForm "frmPaymentsUncompleted", , , "BookingDate >= :" & Me.txtBeforeDate & ": and BookingDate <= :" & me.txtUntilDate & ":"

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by RuralGuy View Post
    Try:
    DoCmd.OpenForm "frmPaymentsUncompleted", , , "BookingDate >= :" & Me.txtBeforeDate & ": and BookingDate <= :" & me.txtUntilDate & ":"
    thanks will try - why the ":" ?

    also it's between dates..

    I get this error with the code now

    Click image for larger version. 

Name:	Capture.JPG 
Views:	14 
Size:	20.3 KB 
ID:	13838

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    The [BookingDate] is the date field in the query of the form that I want to open between the dates of the first form using the text boxes.

    I replaced it with

    DoCmd.OpenForm "frmPaymentsUncompleted", , , "BookingDate >= #" & Me.txtBeforeDate & "#and BookingDate <= #" & me.txtUntilDate & "#"

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I am going to say this is resolved unless someone corrects because it seems to work...

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're right, the octothorp "#" is the DateTime delimiter and not the colon ":". My bad!

  7. #7
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by RuralGuy View Post
    You're right, the octothorp "#" is the DateTime delimiter and not the colon ":". My bad!
    no no, it's all good

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

Similar Threads

  1. DoCmd.OpenReport WHERE condition
    By bidbud68 in forum Programming
    Replies: 16
    Last Post: 10-19-2012, 05:31 AM
  2. Button to open form with a Where condition
    By Newbie2 in forum Forms
    Replies: 3
    Last Post: 08-07-2012, 01:19 AM
  3. DoCmd OpenReport ... where condition with a Like
    By Grooz13 in forum Programming
    Replies: 4
    Last Post: 08-31-2010, 09:04 AM
  4. Select / DoCmd to open another form
    By chrisjack001 in forum Access
    Replies: 1
    Last Post: 08-24-2010, 12:31 PM
  5. Open Report or Form depending on condition
    By jheintz57 in forum Forms
    Replies: 5
    Last Post: 03-12-2010, 08:16 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