Results 1 to 6 of 6
  1. #1
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    175

    Deleting records on a form using VBA

    I have a sub form (sfProposal) linked to its master using the side by side method. Data in inputed into the sub form. This requires several records as each item on a job requires a separate record. Once it is all correct, a button is pushed. This does many calulations putting the data into other tables and finally on other sub forms.

    Problem 1. The sub form, sfProposal, has done it job and the records need to be deleted. When I run the code "DoCmd.RunCommand acCmdDeleteRecord", I get a msg box saying "This record can't be deleted". I can delete the records manually. Also I can delete the records in the table using DAO, but on the form, each field on each record shows "#deleted".

    Problem 2. In this same form, I am unable to move from one field to another using code "DoCmd.GoToControl "tbDblQuanity"". I get error code "There is no field named "tbDblQuanity" in the current record". Beleive me, it is there. I have tried every field using the field name and the control name.



    Any help is appreciated.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    What kind of control is tbDblQuanity?

    Where are you trying to use this code?

    Linq ;0)>

  3. #3
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    175
    It is a datasheet field on a tab control on a sub form. I have a button on the same tab control that runs the code.

  4. #4
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    175
    I stated the previous wrong. The sub form (sfProposal) and the button are on the same tab control which is on a master form. Teh sub form (sfProposal) is not linked to any form. A tab control is just a handy place to put it.

  5. #5
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180

    Deleting records on a form using VBA

    Are you Refreshing or Requerying the Form after running your Delete Query? This should remove the #Deleted.

  6. #6
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    175
    The refresh works great. Thank you very much. That was one of my 2 problems. I think I will show this one solved and open another for the other problem. Again, thank you very much.

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

Similar Threads

  1. Replies: 1
    Last Post: 08-09-2011, 11:26 PM
  2. deleting records
    By radicalrik in forum Queries
    Replies: 2
    Last Post: 07-14-2010, 03:10 PM
  3. deleting records off a subform
    By jamin14 in forum Programming
    Replies: 10
    Last Post: 04-22-2010, 08:47 PM
  4. Replies: 3
    Last Post: 03-25-2010, 12:31 PM
  5. Problem Deleting Records with ADO
    By bdicasa in forum Programming
    Replies: 0
    Last Post: 08-21-2008, 09:27 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