Results 1 to 5 of 5
  1. #1
    willmafingerdo is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    108

    need help w/ VBA code for onclick() for looking up records


    Hello,
    I have a combo box w/ 6 search criteria (EmpID, EmpName, ect..) i tried building the onclick() resopnse in the macro builder but i could not fit all the criteria into the line. i dont even know where to start and all the searchign i have done has just been people showing how to open and close windows.. not look up data entered into a text field... If i could get some help w/ getting started i think i would be alright.. this is what i got for the code for the macro builder and it works i just cant fit all the criteria in due to text length limits:

    [Emp_ID] Like "*" & [Forms]![frm_WIGI_Search]![txt_Search_Box] & "*" Or [Emp_Name] Like "*" & [Forms]![frm_WIGI_Search]![txt_Search_Box] & "*" Or [WGI_Due_Dt] Like "*" & [Forms]![frm_WIGI_Search]![txt_Search_Box] & "*"

    but i need the rest of this added to that:

    [Date_LEI] Like "*" & [Forms]![frm_WIGI_Search]![txt_Search_Box] & "*" Or [AO_Code] Like "*" & [Forms]![frm_WIGI_Search]![txt_Search_Box] & "*" Or [WIGI_Approval_Status] Like "*" & [Forms]![frm_WIGI_Search]![txt_Search_Box] & "*"

    I tried looking at the SQL from a qurey i designed but it didnt help much..

  2. #2
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Well, given what you have posted, I wouldn't know where to start either because there is not enough info.

    Would you explain a little more about what you arer trying to do?
    What is the table name?
    There is only one combo box? What is the SQL of the row source for the combo box?

    What data types are the fields: (I've added my guesses)
    [Emp_ID] - Number?
    [Emp_Name] - Text
    [WGI_Due_Dt] -Date/Time?
    [Date_LEI] - -Date/Time?
    [AO_Code] - Text?
    [WIGI_Approval_Status] - Text?

    This is important because Text type fields and Date/Time fields need/require delimiters.
    Using "Like" with a number field is mostly useless.




    Maybe this article by Allen Browne will help
    Search Criteria Article

    Search Criteria Code

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    You have not provided enough info for readers to understand your issue in context.
    Here's a link to one of the best articles on search -assuming that's what looking up represents.
    If it isn't the answer to your issue, it should certainly provide sufficient info to get started with a plan.
    Good luck with your project.

  4. #4
    willmafingerdo is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    108
    Hello,
    Sorry for the lack of info, I initially wanted to have text boxes for all 6 fields and have one search button to search for any values entered into the text boxes. I couldnt get that to work so i narrowed it down to just a combo box where the user would pick the main search criteria (EmpID, EmpName...). i have a split form so once the user selects the search criteria, enters in the search value and clicks the search button it will pull in the data for the fields on the form.

    I am not sure how to get the SQL for the combo box, i used the wizard to get the values i wanted. sorry for my job i only use Access like once ever year or two so i learn a lot of new stuff.. then i dont get to use it, so i loose it

    Ssanfu, you were correct on the data types for the fields. and these are the options from the combo box also

    [Emp_ID] -
    Number
    [Emp_Name] - Text
    [WGI_Due_Dt] -Date/Time
    [Date_LEI] - -Date/Time
    [AO_Code] - Text
    [WIGI_Approval_Status] - Text

    Orange, that article looks like what i have been trying to find. definitely gonna check that out.. i apologize for my lack of info and knowledge.. and i really appreciate all the help all the users on this board give!!

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    with regards your date/time fields, be aware that what you see is just a formatted view of a number - today is stored as 43882 for example

    so searching for '/6/' will not return the 6th of a month or the month of June (depending on your default date view) or in the case of searching for 'Jan' will not find Jan or January

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

Similar Threads

  1. OnClick Code to Open a Hyperlink Partially Working
    By PSSMargaret in forum Programming
    Replies: 13
    Last Post: 05-10-2017, 09:40 AM
  2. Save Multiple records onClick
    By Tambe257 in forum Programming
    Replies: 18
    Last Post: 03-21-2017, 08:28 AM
  3. OnClick event to view Total Count records
    By wnicole in forum Forms
    Replies: 5
    Last Post: 11-16-2015, 11:55 AM
  4. OnClick not firing
    By richard1941 in forum Access
    Replies: 4
    Last Post: 01-06-2015, 05:27 PM
  5. Set onclick via VBA
    By Gerry in forum Programming
    Replies: 6
    Last Post: 04-19-2010, 09:23 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