Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    No idea, very bizarre as I cannot replicate the issue with your db. Are we following the same steps as shown in my previous post? Have you tested on different computer?
    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
    tim_tims33 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    62
    Yes i have. Here is the code i've used... could you check the end bit? (I changed the date field in tblInvoice to InvDate and the date field in tblInvoiceArchive to ArchiveDate)

    CurrentDb.Execute "INSERT INTO tblInvoiceArchive([Invoice ID],[Member ID], [ArchiveDate])SELECT [Invoice ID],[Member ID], [InvDate] FROM tblInvoice
    WHERE ([InvDate] < # " & (Date - Me.txtDays) & "#)"

    When i enter any value from 1 - 10 i get no results appended. However, when i enter 11...then all the records for Nov and Oct appear. Dec ones don't appear until i enter 50 as the number of days!! Interesting..but unsolvable!

    thanx june

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Changing field names was good idea. Although the name ArchiveDate might be misleading as this is still the invoice date, not the date archive took place.

    Your code is fine. I made those edits to db and still can't replicate the issue. All 8 records are copied to tblInvoiceArchive. I am using Access 2007, Windows XP.

    Try this:

    1. Fix the append query qappInvoices with parameter reference to the textbox (copy/paste into SQL View):
    INSERT INTO tblInvoiceArchive([Invoice ID], [Member ID], [ArchiveDate]) SELECT [Invoice ID], [Member ID], [InvDate] FROM tblInvoice
    WHERE [InvDate] < Date() - Forms!frmARCHIVE.txtDays;

    2. code to run the query
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qappInvoices"
    DoCmd.SetWarnings True
    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.

  4. #19
    tim_tims33 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    62
    Yes! This works fine..... that's helpful June thanks. I'll probably press on with this solution ...but will keep on eye on this thread if a reason is found why your DML insert didn't work on my db.
    You're a legend! cheers

  5. #20
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    It did work in your db, just not on your system under Access 2003. No idea why. I thought Access 2003 had CurrentDb.Execute method available. If the compiler didn't bug on that line, then it should be good code. Very odd.

    Another alternative to try:
    DoCmd.SetWarnings False
    DoCmd.RunSQL "INSERT INTO tblInvoiceArchive([Invoice ID],[Member ID], [ArchiveDate]) SELECT [Invoice ID],[Member ID], [InvDate] FROM tblInvoice WHERE [InvDate]< #" & Date - Me.txtDays & "#"
    DoCmd.SetWarnings True
    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. Replies: 9
    Last Post: 06-28-2012, 10:10 PM
  2. data field in query twice based on criteria
    By sandyg in forum Queries
    Replies: 1
    Last Post: 09-29-2011, 07:47 AM
  3. Crosstab Criteria or Parameters
    By lukewarmbeer in forum Access
    Replies: 3
    Last Post: 08-11-2010, 09:57 AM
  4. Replies: 0
    Last Post: 07-27-2009, 07:51 AM
  5. Open form based on Subform criteria
    By Suzan in forum Programming
    Replies: 0
    Last Post: 04-25-2006, 02:28 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