Results 1 to 10 of 10
  1. #1
    Wayne311 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    91

    AcTableView


    I have a form for user data entry. I need to delete some records using the form with the following code:
    DoCmd.OpenTable "CaseNumber", acViewNormal, acEdit
    DoCmd.SetWarnings False
    DoCmd.GoToRecord acTable, "CaseNumber", acFirst
    DoCmd.RunCommand acCmdDeleteRecord
    Me.Refresh
    DoCmd.SetWarnings True

    The problem is that it opens the table for the user. I want just the form visible to the user. Any way to open the table to delete records without the user seeing it?

    Thanks
    Wayne

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    yes...you open the recordset of the form using a recordsetclone and delete your data that way. afterwards, some records on your form with show "#deleted" if you don't requery it after deleting it's own data.

  3. #3
    Wayne311 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    91
    Quote Originally Posted by ajetrumpet View Post
    yes...you open the recordset of the form using a recordsetclone and delete your data that way. afterwards, some records on your form with show "#deleted" if you don't requery it after deleting it's own data.
    Hey Adam,

    Recordset is new to me. The table that I am opening and deleting records from is a lookup table with only one record in it. It is not a table related to the form. Can I still use a recordsetclone for that?

    Wayne

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    the recordsetclone is just what it sounds like - a clone of the recordset that's actually bound to the form. if that table you're playing with is not bound to that form, then you either have to run an sql executable statement to delete the record, OR you have to open the recordset using vba coding and delete it there.

    (which of course, sql is easier and always recommended, given these two opt's)

  5. #5
    Wayne311 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    91
    Quote Originally Posted by ajetrumpet View Post
    OR you have to open the recordset using vba coding and delete it there.
    I thought that was what I did...

    Wayne

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by Wayne311 View Post
    I thought that was what I did...

    Wayne
    so...........................................????

  7. #7
    Wayne311 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    91
    Thanks, the SQL statement works:

    DoCmd.SetWarnings False
    strSQL = "DELETE * FROM CaseNumber "
    Me.Refresh
    DoCmd.SetWarnings True
    Me.Refresh
    Me.[CRNumber].SetFocus

    That was much less complicated.

    Wayne

  8. #8
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    make sure to always refresh those forms twice too, as the first time never proves to work.

  9. #9
    Wayne311 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    91
    Did I tell you that I work for the Dept. of Redundancy Dept.?

    Thanks (for the humor)
    Wayne

  10. #10
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    no Wayne, you don't.

    the perceived "redundancy" that should be popping up is still there, but new redundancy is requiring more hiring. The more problems the government causes, the more we have to pick it up, and stay employed.

    no complaints here!

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

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