Results 1 to 4 of 4
  1. #1
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199

    Deleting query

    Hi i have written a query:



    Dim fdate As Date
    Dim tdate As Date

    On Error GoTo Err_cmd_Details_exp_Click

    frdate = from_date.Value
    todate = To_date.Value
    DoCmd.DeleteObject acQuery, "qryTemp1"
    If (from_date.Value <> "") And (To_date.Value <> "") Then
    'Me.Form.RecordSource = "select * from Master where Created_Date between #" & fdate & "# And #" & tdate & "# order by Checked_Date desc"
    Me.RecordSource = "select * from Master_Log where Date_processed between #" & frdate & "# And #" & todate & "# order by Date_processed desc"
    CurrentDb.CreateQueryDef "qryTemp1", Me.RecordSource
    'DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryTemp1", "Z:\Intel\Redemptions\APAC\Yebhi.com\Master_Report .xls"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryTemp1", "E:\Yebhi\Master_Report.xls"
    'DoCmd.DeleteObject acQuery, "qryTemp"
    MsgBox "file Exported Z:\Intel\Redemptions\APAC\Yebhi.com\Master_Report. xls"
    End If

    which is deleting the qrytmp1 but not writing again.
    Please Solve

  2. #2
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    1) I see two different spellings of fdate/frdate and todate/tdate. Doesn't look like a problem, but I'd fix the ones that are different, and explicitly Dim the ones you are using.

    2) Try Dim-ing and setting a string variable to the desired SQL first, verifying that it looks good via a msgbox, then using that to create the query. When that's all done, then assign the query to the RecordSource.

    3) If you don't like that option, then put an "else" msgbox in case (from_date.Value <> "") And (To_date.Value <> "") is not true, and put a Msgbox Me.RecordSource statement after you set the RecordSource and see if the SQL looks as expected.

  3. #3
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199
    Thanks it worked

  4. #4
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    1) Which one worked?
    2) Please mark thread "Solved". Top of Page, under "thread tools".

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

Similar Threads

  1. Dropping/deleting linked tables in VBA or query
    By dumbledown in forum Access
    Replies: 3
    Last Post: 04-05-2012, 08:43 AM
  2. Replies: 8
    Last Post: 02-03-2011, 09:51 AM
  3. Replies: 11
    Last Post: 12-14-2010, 01:25 PM
  4. Delete Query Deleting Too Much
    By TundraMonkey in forum Queries
    Replies: 6
    Last Post: 06-30-2009, 02:39 PM
  5. Delete query, deleting customers froma table.
    By keithsrobinson in forum Queries
    Replies: 2
    Last Post: 02-14-2006, 11:33 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