Results 1 to 3 of 3
  1. #1
    memberFDIC is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    5

    Creating a filter using double precision numbers


    I am trying to create a filter where the criteria are numbers, not text strings. So far, I have been unsuccessful. I keep getting "Type 13 Mismatch" errors in my VBA code when line execution reaches the following:

    Me.Results.Form.Filter = "PROJECTEASTING > " & (CDbl(TextStringProjectEasting) - CDbl(TextStringDistance))

    I have tried various string formatting tweaks, such as the one below, but still I have no success:

    Me.Results.Form.Filter = "(PROJECTEASTING > " & (CDbl(TextStringProjectEasting) - CDbl(TextStringDistance)) & ")"

    In the above, PROJECTEASTING is a double precision number and corresponds to a field in my table. TextstringProjectEasting and TextStringDistance are defined at the opening of the form as a TextStrings and then get their values from user input from text boxes. Results is a subform.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I have no idea what is wrong here (but seeing that no one else has responded!) - here's some debugging tips, or what I would do if I were trying to figure this out.

    Separate the issues and step through the code, such as:
    Dim First as Double, Second as Double
    First= CDbl(TextStringProjectEasting)
    Second=CDbl(TextStringDistance)

    Also, things like "Me.Results.Form.Filter = "(PROJECTEASTING > " & 123 - 101)" i.e. make up numbers to see if that line is working correctly.

    Then use f8 to step through the code line by line, you can see the value of each field and each instruction before and after it happens. Hopefully this will immediately make it obvious where it is failing.

  3. #3
    memberFDIC is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    5
    I finally got the filter to work. Thank you for your suggestions. It turned out that the 2 TextString values were empty, and triggered an error when the CDbl function was applied to an empty string value.

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

Similar Threads

  1. Creating Incremental Receipt Numbers
    By JorgeCUC in forum Queries
    Replies: 15
    Last Post: 08-25-2011, 08:50 AM
  2. Double Precision
    By geoff.g in forum Import/Export Data
    Replies: 1
    Last Post: 08-08-2011, 08:26 PM
  3. Creating FILTER Buttons
    By Kipster1203 in forum Forms
    Replies: 9
    Last Post: 06-17-2010, 09:31 AM
  4. Creating a simple filter
    By Kipster1203 in forum Reports
    Replies: 3
    Last Post: 05-18-2010, 10:00 AM
  5. Replies: 3
    Last Post: 10-18-2009, 08:38 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