Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2011
    Posts
    5

    Query Criteria causing a headache

    Hi,

    I'm having a problem with some query criteria and I'm not sure why it itsn't working.

    I have a form with several drop boxes that allow the user to select a Chemical element symbol (C, H, N, O etc.). Next to these boxes I have a text box that allows them to enter a number. The idea is they can use these to build up a chemical formula (C3H7NO2) and then search this against a column in a table that contains chemical formulas and return the ones that match the formula entered.

    I have tried the following code Like "*" & [Forms]![SearchF]![ElementOne]&"*"&[Forms]![SearchF]![ElementNumberOne]&"*" etc. but it doesn't work.



    Can anyone help with this?


    It would also be good if the letters and number could be in any order in the dropdown boxes, i.e. C6H2N2O2 would return C6H2N2O2 and C6N2H2O2 etc.

    Is this possible?

    Many thanks,

    Gavin.

  2. #2
    Rod is offline Expert
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    I think your problem is that you are missing quotes in the resultant string. There's also possibly an unwanted asterisk.

    The syntax when typed from scratch is:

    "*C6*"

    Your string concatenation will result in:

    *C*6*

    So try:

    """*" & [Forms]![SearchF]![ElementOne] & [Forms]![SearchF]![ElementNumberOne] & "*"""

  3. #3
    Join Date
    Jul 2011
    Posts
    5
    Hi,

    Thanks Rod, I found that it was referencing the ID in the second table rather than the Elements so was only searching for numbers. Got it sorted now,

    Cheers,

    Gavin.

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

Similar Threads

  1. Reference Table causing row duplication
    By nbballard in forum Access
    Replies: 0
    Last Post: 06-23-2011, 10:48 AM
  2. Huge Query Headache
    By Gary in forum Access
    Replies: 1
    Last Post: 08-09-2010, 07:35 AM
  3. Dsum causing speed issue
    By ethoemmes in forum Queries
    Replies: 0
    Last Post: 07-06-2010, 05:22 AM
  4. vbCrLf is causing square box on last line
    By cowboy in forum Programming
    Replies: 1
    Last Post: 03-24-2010, 10:01 AM
  5. Replies: 3
    Last Post: 08-06-2009, 11:49 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