Results 1 to 5 of 5
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    348

    Building a query

    After testing a query in Query designer, is there any way to convert it to VBA (handling the chr$(34)s?


    I know you can save it and use it but what if some part of the WHERE clause needs to change?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    Post an example of what you're dealing with? The answer is probably concatenation, but that's a guess.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    348
    Apologies @Micron, I did reply but it didn't make it here. Was just saying I had no example but were there any general rules etc.
    But Colin has saved the day and the "sql2vba" is spot on and just what was needed. So thanks to you both.
    One last question - and I think I'm correct - if only one table is involved you never need the tablename & "." in the query?

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    and I think I'm correct - if only one table is involved you never need the tablename & "." in the query?
    almost - the tablename is required to identify which field you are referring to. If the field name is unique across all the tables in your query, then you don't need the tablename. One of the reasons I recommend that with a few exceptions (such as the FK field) field names should be unique across the project, not just the table. So SaleDate, PaidDate rather than just Date (which is a reserved word anyway).

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

Similar Threads

  1. Building a report on a Crosstab Query
    By BishoyMaher in forum Reports
    Replies: 2
    Last Post: 04-02-2018, 01:33 AM
  2. Replies: 4
    Last Post: 08-27-2017, 07:27 AM
  3. VBA Not Building Query
    By jo15765 in forum Programming
    Replies: 2
    Last Post: 03-16-2017, 12:42 PM
  4. Trouble with building query in VBA...
    By sstiebinger in forum Programming
    Replies: 4
    Last Post: 08-21-2015, 09:13 AM
  5. Building a Query that can extract data and sum
    By Sara Bellum in forum Queries
    Replies: 5
    Last Post: 03-15-2013, 08:57 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