Results 1 to 4 of 4

Thread: VBA Access Searching...

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    VBA Access Searching...

    Hey,
    I am looking for a way to search a table of only 2 columns. The first column will have the numbers I am searching and the second column with have descriptions of those numbers. Some of the numbers are yet to recieve descriptions. I would like to be able to perform a search a for a number and return whether or not it has a description. Anyone have a decent idea on how to do this?

    Thanks

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: VBA Access Searching...

    VB Code:
    1. "SELECT Col1, Col2 FROM Table1 WHERE Col2 = '';"
    DEpends on your Col2 field data type. If its text then that will work.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: VBA Access Searching...

    Depends on how you are outputting it.

    if straight from Sql (bound for example)
    Code:
    "SELECT Col1, iif(nz(len(Col2),0)=0,"-- Not Set --",Col2) FROM Table1"
    If you are looping through code then put a check for isnull and for zero length. If its either of these then print up "--not set--" in that part, otherwise put in the fields contents

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: VBA Access Searching...

    Well I am getting a number from a form then I want to search column 1 to make sure its there, if its there I need to know if it has a description in column2. I would like to be able to have a msgbox pop up if the number not found or if the number is found and there is no description...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width