Results 1 to 7 of 7
  1. #1
    propwash is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    3

    SQL vs VBA

    I have Access 2019 in Office Professional


    I'm new here and to Access. I've done minor dbase stuff with much earlier programs like Approach, DbaseIII and others from the early 90's. So I ask which programming language should I lean towards, VBA or SQL? I'm struggling with making queries with 4 different choices with the possibility of 2 or 3 choices being no selections; ie, Make Model City County.
    THANKS for the help.
    Danny

  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
    Apples and oranges, both would be used in a moderately complex app. You can do a lot in the query design grid without needing sql. What you describe could be done with a single parameter query:

    http://www.theaccessweb.com/queries/qry0001.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    You can do a lot in the query design grid without needing sql.
    Just to add to paul's post, you learn a lot about sql by writing a query in the design grid and then switching to sql view to see the syntax.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    I'm struggling with making queries with 4 different choices with the possibility of 2 or 3 choices being no selections; ie, Make Model City County.
    you would either build the sql in VBA to create a query (i.e. only include criteria where there is a value) or in a query you would use 'or criteria is null'.

    Would really need to see some example data and the outcome you require but perhaps something like this

    Code:
    SELECT *
    FROM myTable
    WHERE (Make=forms!myform!cboMake OR forms!myform!cboMake is null) AND (Model=forms!myform!cboModel OR forms!myform!cboModel is null)... etc

  5. #5
    propwash is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    3
    Ajax... Thanks for the help. I see where I wasn't headed towards. On a second note, I can't get the combobox to show unique choices ie I have maybe 20 of the same make and only show 1 of each make. I've changed the properties of the query to be UNIQUE VALUES to yes, but all the makes still show. Any idea what I'm missing?
    THANKS
    Danny

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    really difficult to say without seeing some data, but would think you either want something like

    select PK, Make FROM tblMakes

    or

    SELECT DISTINCT Make FROM tblVehicles

  7. #7
    propwash is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    3
    Ajax... THANKS. This is kind of what I wanted to know about either using SQL or VBA for programming
    Danny

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

Tags for this Thread

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