Results 1 to 4 of 4
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Adding to Criteria


    I am trying to add in a form entry into the criteria of a field in a query. The addition will affect 6 queries at the same time.

    Something like Between Date() And Date()- & [Forms].[FrmSettings].[DayNum]

    This number will change at different dates for different amounts.

    Default Value = 6

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Try

    Between Date() And Date()- [Forms].[FrmSettings].[DayNum]

    or

    Between Date() And DateAdd("d", -[Forms].[FrmSettings].[DayNum], Date())

    It looks like the second date will be earlier, in which case I'd reverse them. Between will often work with the lower number second, but I've seen it fail. I always put the lower value first.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Thanks Paul,
    I think I have it, but in a less elegant way:

    Code:
    Private Sub Exit_Complete_Click()
       DoCmd.RunCommand acCmdSaveRecord
           DoCmd.OpenQuery "QryDayNumTbl", acViewNormal, acEdit
                   DoCmd.OpenQuery "QryUpDayNum", acViewNormal, acEdit
    
       DoCmd.SetWarnings False
       DoCmd.DeleteObject acTable = acDefault, "TblDayNum"
       DoCmd.SetWarnings True
    
        DoCmd.Close ,""
        DoCmd.OpenForm"frmStart", acNormal, "", "", , acNormal
    End Sub
    2 Queries referenced:
    QryUpDaynum
    Code:
    UPDATE TblChangeRequest, TblDayNum SETTblChangeRequest.DayNum = [TblDayNum].[DayNum]
    WHERE (((TblChangeRequest.CRID)>1));

    And
    qryDayNumTbl
    Code:
    SELECT TblChangeRequest.DayNum INTO TblDayNum
    FROM TblChangeRequest
    WHERE (((TblChangeRequest.CRID)=1));
    Suggestions on a more eloquent way is accepted happily


    Grazi

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Glad you got it working. I'm not following what you did (I'm blaming the half-bottle of wine) so I can't offer any improvements.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. adding an iff statement as criteria in dcount
    By Thompyt in forum Programming
    Replies: 6
    Last Post: 02-24-2018, 09:29 AM
  2. Adding Criteria in MsgBox DSum sub
    By bsegge in forum Programming
    Replies: 12
    Last Post: 11-07-2016, 12:51 PM
  3. Replies: 3
    Last Post: 12-10-2013, 11:37 AM
  4. Help with adding criteria
    By aubtiger14 in forum Queries
    Replies: 5
    Last Post: 12-05-2013, 10:39 AM
  5. Adding an image if criteria met
    By cjohnston in forum Programming
    Replies: 2
    Last Post: 03-03-2012, 10:27 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