Results 1 to 5 of 5
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Setting RecordSource Dyamically

    I'm setting the where clause for a query (the forms recordsource). On a numeric field if the user does not set a value, l want to select all records. I thought the simplest solution would be set the criteria to be Like "*", but this does not work. I am contructing this like so;

    if cboFilter.value = cboFilter.defaultvalue then
    Filter1 = [myFieldName] & " Like '*' "


    Else
    Filter1 = [myFieldName] & " = " & me.cboFilter
    End if

    Hope you can help. I'm under a deadline

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if you're setting the filter you also have to set the filter on

    In the design view of your report go to the FILTER ON LOAD property and change it to YES.

  3. #3
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    This aren't filters really, they are criteria in a WHERE statement of a query. The problem is Numeric Fields don't like Like "*". as a fix I just substituted ">0". I just was looking for a numeric substitute to "*"

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    is not null would search a numeric field that had any value other than null

  5. #5
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Thanks

    rpeare,

    I forgot to thank you. This work just fine and also helped me locate records where this value WAS null.

    Paul

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

Similar Threads

  1. Replies: 3
    Last Post: 08-28-2011, 08:24 PM
  2. Replies: 8
    Last Post: 08-08-2011, 02:05 PM
  3. Setting Recordsource for Subforms
    By P5C768 in forum Forms
    Replies: 5
    Last Post: 11-16-2010, 05:01 AM
  4. Update Subform Recordsource
    By mystifier in forum Forms
    Replies: 8
    Last Post: 11-15-2010, 03:03 AM
  5. RecordSource help
    By mann2x in forum Access
    Replies: 3
    Last Post: 10-05-2010, 06:44 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