Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Unfortunately, if there are no records returned then the calculated field will have nothing to calculate with. And an UPDATE certainly will not accomplish anything.

    Alternatives:

    1. query object with a single record and calculated field (which can dynamically include month name and year if you want) - code determines which query to export


    SELECT DISTINCT "Nothing to report month of " & [enter month year or reference textbox on form] AS F FROM yourtablename;

    2. Maybe build a report based on the query. If no records returned, a textbox or label can display with the notation "Nothing to report this month". A simple report can export nicely to Excel

    3. 'dummy' record in table with the "Nothing to report this month" entry - filter query to exclude or include that record as determined by code

    4. code manipulates query to modify its structure and content
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  2. #17
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    June, my point was that you insert into a table via a (select) query, not into a query.

    OP, have you tried my suggestion? You don't do that in VBA, but in the QDE (the query design interface) - you switch to SQL and copy and paste that replacing the name of the table then you save it as a new query then you export that instead of the original QmatQselBenefitsToTblPermBenefits:
    Code:
    SELECT QmatQselBenefitsToTblPermBenefits.[LastName] FROM QmatQselBenefitsToTblPermBenefits
    Union
    SELECT "No additions to report this month" As [LastName] FROM tblYOUR_VolunterTable;
    Cheers,
    Vlad

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Vlad, think we essentially tried to convey the same info.

    Also think we are on similar track about code determining which query to send. See my option 1 in prior post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Insert into query vba
    By jaryszek in forum Access
    Replies: 4
    Last Post: 07-28-2017, 05:00 AM
  2. Replies: 1
    Last Post: 08-29-2016, 07:50 PM
  3. Replies: 3
    Last Post: 05-27-2015, 01:04 PM
  4. INSERT query: insert new data only
    By drh in forum Access
    Replies: 2
    Last Post: 04-04-2014, 05:31 PM
  5. INSERT INTO query in VBA
    By jgelpi16 in forum Programming
    Replies: 5
    Last Post: 09-17-2010, 02:19 PM

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