Results 1 to 4 of 4
  1. #1
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162

    Cant see where its wrong - VBA wildcard search.

    Hi guys,

    I cant see where my code is incorrect, but obviously it is ats Im getting the error type mismatch:



    Code:
            Case "Current User"
        MySQL = "SELECT TimesheetTable.sUser, TimesheetTable.Activity, TimesheetTable.Hours, TimesheetTable.Project, TimesheetTable.[Task Date], TimesheetTable.Description FROM TimesheetTable "
        MySQL = MySQL & "WHERE (((TimesheetTable.sUser)=[Forms]![TotalHours_Frm]![CurrentUser]) AND ((TimesheetTable.Project) Like " * " & [Forms]![TotalHours_Frm]![ProjectRef_txtbox] & " * ")"
    Will someone put me out of my misery please?

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Does this work?


    Code:
    MySQL = MySQL & "WHERE (((TimesheetTable.sUser)=[Forms]![TotalHours_Frm]![CurrentUser]) AND ((TimesheetTable.Project) Like '*" & [Forms]![TotalHours_Frm]![ProjectRef_txtbox] & "*')"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Add a line (Paul's example)

    Code:
    MySQL = MySQL & "WHERE (((TimesheetTable.sUser)=[Forms]![TotalHours_Frm]![CurrentUser]) AND ((TimesheetTable.Project) Like '*" & [Forms]![TotalHours_Frm]![ProjectRef_txtbox] & "*')"
    Debug.Print MySQL
    Set a breakpoint and look at the result.

    I think you might also have to concatenate reference to the first form if this is in code and not in a query.
    Code:
    MySQL = MySQL & "WHERE  (((TimesheetTable.sUser)= '" & [Forms]![TotalHours_Frm]![CurrentUser] & "') AND  ((TimesheetTable.Project) Like '*" &  [Forms]![TotalHours_Frm]![ProjectRef_txtbox] & "*')"
    Debug.Print MySQL

  4. #4
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162
    Fandabby dozey guys... Worked a treat, thanks!

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

Similar Threads

  1. Filter with wildcard
    By gg80 in forum Programming
    Replies: 8
    Last Post: 10-07-2011, 06:29 PM
  2. If OR statement (maybe a wildcard?)
    By Lorlai in forum Queries
    Replies: 5
    Last Post: 07-27-2011, 10:21 AM
  3. replace a character with a wildcard
    By neeedhelp in forum Programming
    Replies: 2
    Last Post: 04-11-2011, 05:02 PM
  4. Wildcard Expressions in Search Field
    By eww in forum Programming
    Replies: 4
    Last Post: 09-29-2010, 10:27 AM
  5. Parameter Query & Wildcard
    By Rick West in forum Queries
    Replies: 8
    Last Post: 12-29-2009, 10:54 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