Results 1 to 5 of 5
  1. #1
    tcox's Avatar
    tcox is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    46

    Like " text box value " SQL

    I'm having difficulty getting access to accept a value in a txtbox for the like parameter in a query.
    This relates to my scrapped use of multi value fields. I'm now entering capsule size separated by spaces for my tooling.
    Ex. 00 0 2 4 is entered in the size column for a particular piece of tooling.


    the above tooling works for 00, 0, 2 and 4 size capsules. I want to query tooling that size contains 00.

    online help only shows tying in Like "00" in the criteria field without mention of using it with form objects

    I'm having trouble formulated the Like statement in design view and/or SQL view.
    Like "Forms![Navigation_Main]![NavigationSubform].Form![txt_capSize]"
    Like '" & Forms![Navigation_Main]![NavigationSubform].Form![txt_capSize] & "'
    Like "Me.txtCapSize.value"
    none of these and many more do not work

    What is the proper way to write an SQL query to search from input from a text box?

    -Tevis

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 64bit Access 2013
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Try this

    strSql = "Like Forms![Navigation_Main]![NavigationSubform].Form![txt_capSize] & ""*"""


    Here is a link that should help in the future.

    http://allenbrowne.com/ser-71.html

  3. #3
    tcox's Avatar
    tcox is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    46
    I'm unsure how to integrate your suggestion into the SQL statement.

    Similar to this?
    SELECT T_Part_Sets.Part_Set, T_Part_Sets.Part_Sets_ID
    FROM T_Part_Sets
    GROUP BY T_Part_Sets.Part_Set, T_Part_Sets.Part_Sets_ID, T_Part_Sets.Machine_Type, T_Part_Sets.Size, T_Part_Sets.Status
    HAVING (((T_Part_Sets.Machine_Type)=[Forms]![Navigation_Main]![NavigationSubform].[Form]![txt_machineType]) AND ((T_Part_Sets.Size) Like [Forms]![Navigation_Main]![NavigationSubform].[Form]![txt_capSize] & ""*"") AND ((T_Part_Sets.Status)="IN"))
    ORDER BY T_Part_Sets.Part_Set;

  4. #4
    tcox's Avatar
    tcox is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    46
    SELECT T_Part_Sets.Part_Set, T_Part_Sets.Part_Sets_ID
    FROM T_Part_Sets
    GROUP BY T_Part_Sets.Part_Set, T_Part_Sets.Part_Sets_ID, T_Part_Sets.Machine_Type, T_Part_Sets.Size, T_Part_Sets.Status
    HAVING (((T_Part_Sets.Machine_Type)=[Forms]![Navigation_Main]![NavigationSubform].[Form]![txt_machineType]) AND ((T_Part_Sets.Size) Like ([Forms]![Navigation_Main]![NavigationSubform].[Form]![txt_capSize] & "*")) AND ((T_Part_Sets.Status)="IN"))
    ORDER BY T_Part_Sets.Part_Set;

    wrapping it in parentheses worked.

  5. #5
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 64bit Access 2013
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Glad to hear you have it working. Did you read Allen Browne's description on how to handle this going forward with the converter he has designed.

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

Similar Threads

  1. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  2. Replies: 1
    Last Post: 09-03-2014, 03:27 AM
  3. Replies: 3
    Last Post: 04-22-2013, 06:08 AM
  4. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  5. Replies: 11
    Last Post: 03-29-2012, 02:32 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