Results 1 to 8 of 8
  1. #1
    sspreyer is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Nov 2013
    Posts
    36

    how to turn my expression in query to vba


    hi , all

    i have calulated expression in column in my query which filters my date field "date start" if i tick my checkbox "filter null" and click my command button on my form, it open my report and only show records with no date in "date start" field and if unticked only shows records that have a date in the "date start Field " some reason doesnt seem work all the time and would like to put it in to vba seem better option

    heres my query expression

    if([forms]![Form1]![filter null] = -1 AND isnull(Date Start), 1, iif([forms]![form1]![filter null] = 0 and not isnull(Date start), 1, 0))

    my vba knowleage is very little hope someone could give me step 2 step guide on how to convert this to vba

    thanks in advnce

    shane

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    If it doesn't always work in query will probably have issues with VBA, but maybe easier to debug.

    Is [filter null] an unbound checkbox?

    Advise no spaces or special characters/punctuation (underscore is exception) in naming convention. Better would be DateStart or Date_Start.

    Name checkbox like cbxFilter

    Something like:

    DoCmd.OpenReport "reportname", , , IIf(Me.cbxFilter = False, "NOT ", "") & "[Date Start] Is Null"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    sspreyer is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Nov 2013
    Posts
    36
    Hi June7
    Thanks yes filter null is unbound checkbox



    shane

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    This is resolved?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    sspreyer is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Nov 2013
    Posts
    36
    Thanks i will try later when I'm home later and will report back

    Yet again thanks for your time

    Shane

  6. #6
    sspreyer is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Nov 2013
    Posts
    36
    Hi June7
    thank you ever so much worked Great adjusted slightly here it is

    Code:
    DoCmd.OpenReport "report2", acViewPreview, , IIf(Me.cbxFilter = False, "NOT ", "") & "[Date Start] Is Null"
    just one more question how can add another filter to this

    sort of like

    Code:
     DoCmd.OpenReport "report2", acViewPreview, , IIf(Me.cbxFilter = False, "NOT ", "") & "[Date Start] Is Null" & IIf(Me.cbx2Filter = False, "NOT ", "") & "[Date completed] Is Null" but this doesn't work have I got wrong expression here?
    any way JUNE7 you legend !!!

    shane

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Try:

    DoCmd.OpenReport "report2", acViewPreview, , IIf(Me.cbxFilter = False, "NOT ", "") & "[Date Start] Is Null" & " AND " & IIf(Me.cbx2Filter = False, "NOT ", "") & "[Date completed] Is Null"
    Last edited by June7; 01-18-2014 at 01:17 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    sspreyer is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Nov 2013
    Posts
    36
    Thanks!!!!!!! June7 worked yet again

    thanks

    shane

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

Similar Threads

  1. How to turn off prompt when running append query from code
    By GraeagleBill in forum Programming
    Replies: 5
    Last Post: 07-22-2013, 03:35 PM
  2. Turn off busy icon when performing Query
    By robrich22 in forum Access
    Replies: 1
    Last Post: 03-07-2013, 09:19 PM
  3. Replies: 2
    Last Post: 11-20-2012, 03:21 AM
  4. Replies: 4
    Last Post: 10-26-2012, 12:49 AM
  5. Replies: 4
    Last Post: 10-17-2012, 07:27 AM

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