Error deleting record - acCmdDeleteRecord isn't available

I have a form and subform combination for entering two related records, an 
Inventory item Master definition and an Inventory item sub definition.  The 
master information is on the main form and the sub definition is on the 
subform.  I have coded logic to delete the master record that is 
automatically written by Access when the user tabs from the main form into 
the subform IN THE EVENT that the user enters no information into the subform 
and exits from/closes the main form using the exit button I've provided.  
When I test this code, I get error 2046 "The command or action 
acCmdDeleteRecord isn't available now." and I cannot figure out why I am 
getting this error.  My code to do this delete, which is in the click event 
of my main form's Exit button, is:
Private Sub cmdExitInvMaster_Click()
On Error GoTo Err_cmdExitInvMaster_Click

    'If Hardware specific record (i.e PC, Router, etc.) not created and Inv 
Class is Hardware, delete Inv Master
    If Not HWMasterExists And IMInvClassID = 1 Then
        Me.IMInvDescr.SetFocus
        DoCmd.RunCommand acCmdDeleteRecord
    End If
    DoCmd.Close

Exit_cmdExitInvMaster_Click:
    Exit Sub

Err_cmdExitInvMaster_Click:
    MsgBox Err.Description
    Resume Exit_cmdExitInvMaster_Click
        
End Sub

Note: HWMasterExists is a function that tests to see if a record was created 
in the subform, and seems to be working fine.  Record source for main form is 
a query over the associate InventoryMaster table. Please pardon if this is 
posted twice -my first posting, and having a bit of difficulty getting the 
hang of it.  Any help will be greatly appreciated.

0
Utf
6/22/2007 7:52:01 PM
access.formscoding 7493 articles. 0 followers. Follow

2 Replies
2431 Views

Similar Articles

[PageSpeed] 15

On Jun 22, 2:52 pm, Tim Peters <TimPet...@discussions.microsoft.com>
wrote:
> I have a form and subform combination for entering two related records, an
> Inventory item Master definition and an Inventory item sub definition.  The
> master information is on the main form and the sub definition is on the
> subform.  I have coded logic to delete the master record that is
> automatically written by Access when the user tabs from the main form into
> the subform IN THE EVENT that the user enters no information into the subform
> and exits from/closes the main form using the exit button I've provided.  

Let me get this straight, you have two separate tables -  a master and
a detail - and you want to delete a record in the master if no
information exists in the detail.  Can I assume that the record was
just added?

> When I test this code, I get error 2046 "The command or action
> acCmdDeleteRecord isn't available now." and I cannot figure out why I am
> getting this error.  My code to do this delete, which is in the click event
> of my main form's Exit button, is:
> Private Sub cmdExitInvMaster_Click()
> On Error GoTo Err_cmdExitInvMaster_Click
>
>     'If Hardware specific record (i.e PC, Router, etc.) not created and Inv
> Class is Hardware, delete Inv Master
>     If Not HWMasterExists And IMInvClassID = 1 Then
>         Me.IMInvDescr.SetFocus
>         DoCmd.RunCommand acCmdDeleteRecord
>     End If
>     DoCmd.Close
>
> Exit_cmdExitInvMaster_Click:
>     Exit Sub
>
> Err_cmdExitInvMaster_Click:
>     MsgBox Err.Description
>     Resume Exit_cmdExitInvMaster_Click
>
> End Sub
>
> Note: HWMasterExists is a function that tests to see if a record was created
> in the subform, and seems to be working fine.  Record source for main form is
> a query over the associate InventoryMaster table. Please pardon if this is
> posted twice -my first posting, and having a bit of difficulty getting the
> hang of it.  Any help will be greatly appreciated.

If the record in the master table hasn't been officially added yet,
then setting Cancel to true in the BeforeUpdate event may work.

0
OldPro
6/22/2007 9:48:42 PM

"OldPro" wrote:

> On Jun 22, 2:52 pm, Tim Peters <TimPet...@discussions.microsoft.com>
> wrote:
> > I have a form and subform combination for entering two related records, an
> > Inventory item Master definition and an Inventory item sub definition.  The
> > master information is on the main form and the sub definition is on the
> > subform.  I have coded logic to delete the master record that is
> > automatically written by Access when the user tabs from the main form into
> > the subform IN THE EVENT that the user enters no information into the subform
> > and exits from/closes the main form using the exit button I've provided.  
> 
> Let me get this straight, you have two separate tables -  a master and
> a detail - and you want to delete a record in the master if no
> information exists in the detail.  Can I assume that the record was
> just added?
> 
> > When I test this code, I get error 2046 "The command or action
> > acCmdDeleteRecord isn't available now." and I cannot figure out why I am
> > getting this error.  My code to do this delete, which is in the click event
> > of my main form's Exit button, is:
> > Private Sub cmdExitInvMaster_Click()
> > On Error GoTo Err_cmdExitInvMaster_Click
> >
> >     'If Hardware specific record (i.e PC, Router, etc.) not created and Inv
> > Class is Hardware, delete Inv Master
> >     If Not HWMasterExists And IMInvClassID = 1 Then
> >         Me.IMInvDescr.SetFocus
> >         DoCmd.RunCommand acCmdDeleteRecord
> >     End If
> >     DoCmd.Close
> >
> > Exit_cmdExitInvMaster_Click:
> >     Exit Sub
> >
> > Err_cmdExitInvMaster_Click:
> >     MsgBox Err.Description
> >     Resume Exit_cmdExitInvMaster_Click
> >
> > End Sub
> >
> > Note: HWMasterExists is a function that tests to see if a record was created
> > in the subform, and seems to be working fine.  Record source for main form is
> > a query over the associate InventoryMaster table. Please pardon if this is
> > posted twice -my first posting, and having a bit of difficulty getting the
> > hang of it.  Any help will be greatly appreciated.
> 
> If the record in the master table hasn't been officially added yet,
> then setting Cancel to true in the BeforeUpdate event may work.
> 
> 

Yes, your assumption that the record in the master table was just added is 
correct.  My understanding is that Access adds the record to the master table 
once the user tabs into the subform in order to maintain referential 
integrity between the parent/master and child tables.  That being the case, I 
want to avoid having this master record sitting in the table if the user 
decides to exit from the form without having entered the associated detail.

As to setting Cancel to true in the BeforeUpdate event if the record hasn't 
been officially added, all I know so far (I'm pretty new to Access and VB) is 
what I just stated regarding Access's default action when tabbing from a main 
form to a subform (which I believe I learned on this site); so, I would have 
to assume that the record has been officially added.

Thanks for your response.
0
Utf
6/22/2007 10:04:00 PM
Reply:

Similar Artilces:

ExMerge 'Error configuring message service'
Hi All, I am running into this error when trying to import a PST into Exchange 2003 SP1 (on SBS 2003): Error configuring message service (MSPST MS) (MAPI_E_EXTENDED_ERROR) (CMapiSession::CreateEMSPSTProfile) I know this matches a KB article exactly, but the PST is NOT read only (I have even made it read only and then not read only just to make sure). I am pretty sure I have correctly removed deny send and receive as. I can export to a PST from the mailbox in question and then re-import the exported PST. The mailbox does not have any limits and does have messages so it is initialize...

stack fault error when browsing address book
I have a problem that occurs when browsing the address book "Contacts" that results in the error message: OUTLOOK has caused a stack fault in MSPST32.DLL and the termination of Outlook I've updated the Win98Se and the Office 2000, tried the steps in the KB218853, and searched the newsgroup and KB to no avail. Also tried the Inbox repair tool (scanpst.exe) which found only minor problems and repaired them. I can look at the entire "Contacts" folder in Outlook without problems. This does not appear to be related to any contact record. Thanks Steve ...

Controlling printed records when report bound to multiple tables
I created a report that uses the control from a form to generate a report based on that record's primary key. This form also has a subform which has relationships tied to the primary key for record identification and is linked to the main table. When preview the report the data from the subform either does not show up in the preview when using the filter [control]=[form]![control].[value] or makes multiple copies of the report equal to the number of entries in the subform's table. Is there any way around this? I have tried queries but have not found a way to use a f...

Case select returning error when cell contains #N/A : how must i avoid this error
Title says it all Thanks, Luc maybe this will do what you want Sub test() If Not IsError(Range("C1").Value) Then Select Case Range("C1").Value Case 1 MsgBox "1" Case 2 MsgBox "2" End Select End If End Sub -- Gary Keramidas Excel 2003 "Luc" <lferr@live.be> wrote in message news:7AB07996-F1EE-41C1-8D9D-8A7DA54CED91@microsoft.com... > Title says it all > > Thanks, > > Luc Thanks for your help !!!!! Luc "Gary Keramidas" <GKeramidasAtMSN.com> schreef in berich...

Error Code: 0x8024D007
Hi all: I have tried pretty much evrything listed here in other discussions. It appears that my last update was January 2010. I am running XP sp3. I would hope by now Microsoft would have a general fix for WUS issues. I know this is a compllex issue but so many people can no longer get updtaes. is this their way of trying to force us all to Win 7? Any help would be appreciated. Thx Michael Michael, The most common cause of error 0x8024D007 is that registry files that correspond to the Wups2.dll file are missing. However, the problem can also be caused by other mis...

power point error
get the following error when double clicking a slideshow in Outlook: Procedure entry point GetProcessImageFileNameW could not be located in the dynamic link library. PSAPI.DLL Originally I thought it could be a problem with PowerPoint 2007 so I had Unistalled the Office suite and reinstalled it however the problem still arised. Even repairing the Office suite did not help. I tried using the sfc /scannow but to no avale. I also tried renaming the PSAPI.DLL to PSAPIOLD.DLL rebooted the machine and then it created a new PSAPI.DLL file. Still the error arises. Then I had tried repar...

Error C2440 cannot convert from void
I got this error a few days ago and after much searching and still stuck on the problem. Any help given will be greatly appreciated. Error 1 error C2440: 'static_cast' : cannot convert from 'void (__thiscall CPage1::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' The error occurred in this code: BEGIN_MESSAGE_MAP(CPage1, CPropertyPage) //{{AFX_MSG_MAP(CPage1) ON_WM_DESTROY() ON_WM_TIMER() ON_BN_CLICKED(IDC_BUTTON_PROV_ADD, OnButtonProvAdd) ON_BN_CLICKED(IDC_BUTTON_PROV_EDIT, OnButtonProvEdit) ON_BN_CLICKED(IDC_BU...

Conversion Errors Table
Hello, I'm new to working with Access, I just converted an Access 97 databas into Access 2002. It tells me there were errors, and to look at th Conversion Errors Table. But nowhere in the message or in the MS Hel is there anything telling me where to find this table. Can someon help? Thanks Patric -- psha ----------------------------------------------------------------------- pshaw's Profile: http://www.officehelp.in/member.php?userid=493 View this thread: http://www.officehelp.in/showthread.php?t=125029 Posted from - http://www.officehelp.i I'd expect to find it in the new...

how to delete Microsoft office
How can i delete microsoft office from my computer. i downloaded the demo but i don't want it anymore. Thank you "Dany" <Dany@discussions.microsoft.com> wrote in message news:B2B2C1A8-2A65-4E97-BE3B-EC2DC2D42107@microsoft.com... > How can i delete microsoft office from my computer. i downloaded the demo > but > i don't want it anymore. Thank you Control Panel, Add and Remove Programs, Microsoft Office, Remove. Dany Or if you cannot as Jeff posted then see the below http://support.microsoft.com/kb/928218 -- Peter Please Reply to ...

Error Msg.
Can anyone decipher this error message: DVZMSGR caused an invalid page fault in module MSVCRT.DLL at 0167:78001296. Registers: EAX=00650078 CS=0167 EIP=78001296 EFLGS=00010202 EBX=0075000c SS=016f ESP=0063f728 EBP=0063f748 ECX=0064fc40 DS=016f ESI=0000003f FS=393f EDX=00650448 ES=016f EDI=0000003f GS=0000 Bytes at CS:EIP: 89 4c 11 fc 8b 75 f0 03 d1 8d 4e 01 89 0a 89 4c Stack dump: 00000000 00000040 780013d0 816d0238 00000050 006503c0 0064fc40 00000001 0063f77c 7800145c 0075000c 00000000 ffffffff 780013d0 bff7b9c5 816d0204 ...

supplier info gets deleted
I have run a report for items in a category in order to organize them into the proper categories & departments I double click the item look up - properties opens - I change the deparment &/or category - OK When I look at these items again - the supplier information is gone - I have to reopen each one and re-enter the supplier! Can anyone tell me why & how to avoid this happening? ALSO in my category report I am finding some suppliers blank - but when I open the properties the supplier is there - I have to delete the supplier & re-add the supplier. Anyone know why &am...

Money 2004 Deluxe Start error after install
After a fresh install of Money 2004 Deluxe in Windows XP Home I get an error box that says "Microsoft Money has encountered an error and needs to close" There is a box checked that says " Restart Microsoft Money" but it never restarts. Th error signature - AppVer: 12.0.0.613 Mod Name: kernel32.dll Offset: 00013887 Under technical information - Exception information Code: 0xe06d7363 Flags: 0x00000001 Address: 0x0000000077e73887 Is this a Windows error or did I waste my money on a software package. Please help - thanks In microsof...

deleting rows #2
i have200 rows in sheet- there are lets say 100 rows the title shipping i have another 100 rows with the title payments. they are in mixed in and not grouped together otherwise i could highlight them all together and delete-how do i delete all the ones that say shipping without clicking on each individual row. I am on excel 2007 trial cb wrote: > i have200 rows in sheet- there are lets say 100 rows the title shipping > i have another 100 rows with the title payments. > they are in mixed in and not grouped together otherwise i could highlight > them all together and delete-how d...

Help Needed With Write Conflict Error Message.
I have an order form that users open and close on a regular basis. The form is based on a query. On the form are two fields, "TicketPrinted" and "RevisedDate". Most of the time the field "Ticket Printed" has a value in it of "Yes". What I want to be able to do is that if a date is entered into this "RevisedDate" field, OR if the information is changed in this "Revised Date" field, that when the user closed the form, an update query runs that changes the "TicketPrinted" field from the original value of "Yes"...

deleting duplicate value in columns
What is the best method to delete rows containing dulicate (same number) numbers in a column (Excel 2000)? The workbook has over 30,000 rows which makes it impractical to sort and then delete the duplicates page by page. Thanks in advance. Hi Jim have a look at http://www.cpearson.com/excel/deleting.htm#DeleteDuplicateRows Frank Jim Brokenshire wrote: > What is the best method to delete rows containing dulicate (same > number) numbers in a column (Excel 2000)? The workbook has over > 30,000 rows which makes it impractical to sort and then delete the > duplicates page b...

Outlook 2007 Outlook.exe deleting itself
I seem to be having a very strange problem. When I start Outlook 2007, it stalls and then deletes the Outlook.exe file. This is a relatively new problem (within the last week). All other files seem to be present. If I keep a full copy of Outlook.ext in another folder, that is also deleted. In some cases, after restoring the file, Outlook will start to come up but then stall and die. In other cases, it won't won't even start to come up but just deletes itself. I've run several different types of anti-virus software including AVG, Avira, Spybot and none seem to find an issue or he...

XmlValidatingReader unbelievable error
Hi everyone, I am trying now for 4-5 hours to write a simple code to validate a very simple XML and i still get an error. Here is my Code, and i always get an error at args.Exception ("The 'urn:books:catalog' element is not declared. An error occurred at file:///c:/inetpub/wwwroot/LakisService/books.xml, (2, 2).") private void Button2_Click(object sender, System.EventArgs e) { XmlTextReader r = new XmlTextReader(Server.MapPath("books.xml")); XmlSchema xs = new XmlSchema(); xs.SourceUri = Server.MapPath("books.xsd"); XmlValidatingReader v = new X...

Warning off by deleting a sheet
Hi Is there away to set warning off when i deleting a sheet in Code Sorry i have found the solution "alvin Kuiper" skrev: > Hi > Is there away to set warning off when i deleting a sheet in Code > ...

Deleting data from a table through a query
I have a database that is designed to update a list of credit union members from a master list so that vehicle insurance coverage can be tracked. I have been able to run an unmatched query to achieve a list of old members who have either paid off their vehicles or moved their loans to other locations. What I need to do now is delete these people from the main table. I have the cascade update and delete funtion in place to delete the vehicle information once the member is deleted, but I don't know how to take the information found in the unmatched query and delete those members fr...

An error number : 424 problem
I'm having trouble with an attachment field. On a report I can see the picture and the filename of the selected attachent properly. Now in a SQL UPDATE string that i'm making I always get the error 424 Object required. Here is the line where it happens : 'mySQL = mySQL + ", scan_g = " & prn_du_pied_g.FileName scan_g is a Text field prn_du_pied_g is an attachment All I want to do is to use the filename of the attchment. How do I solve this Thank you for the help -- Eric "ericb" <eric@b.com> wrote in message news:9A...

check for workstation availability on local network
Hi can any one tell me how can I check for availability of different computers on my local network? I want to have my MFC application to monitor my home network to check which pc's are turned on and connected to network.please guide me to classes which can help. thanks alot Don't expect to find predefined classes for this. There are a lot of network APIs, however, look for WNetOpenEnum and associated APIs. joe On Wed, 22 Oct 2008 22:28:23 +0330, "HASAN" <hasan.musavi@gmail.com> wrote: >Hi >can any one tell me how can I check for availability of diffe...

Auditing form on record change
HI, I have a form with multiple fields that I want to track changes to. I was able to create a auditing trail when users click on particular buttons however if they dont click on the buttons the auditing does not occur. What I am wanting to do is to run the audit when a user changes to a new record. I have tried the "on current" and "before update" but they didnt work. Any suggestions? Take a look at what Allen Browne has at http://www.allenbrowne.com/AppAudit.html -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "...

replace error by value
Hi, Can anyone tell me how I can change an error msg (f.e. #DIV/O!) by any value ? I have a formula that generates an error msg, but I want to change it by ZERO. Thanks, Fabian =IF(ISERROR(your_formula),0,your_formula) HTH Jason Atlanta, GA >-----Original Message----- >Hi, > >Can anyone tell me how I can change an error msg (f.e. >#DIV/O!) by any value ? > >I have a formula that generates an error msg, but I want >to change it by ZERO. > >Thanks, >Fabian >. > Hi change your formula to something like =IF(B1=0,0,A1/B1) -- Regards Frank Kabel Fra...

Business Portal Error During Installation
Hi, I am trying to install Business Portal 2.0, I have prepared a Share Point Server with windows 2003 installed, but when I try to install Business Portal it si giving me this error message "The database (Comany ID) on SQL Server (Server Name) does not meet minimum requirements-your back office data must be at vesion 7.x" although our Great Plains version is 7.5 with service pack 1 installed. Any suggestions about this issue will be highly appreciated. Mohammad, Thanks for using the newsgroup. I have seen this error before. In the cases I saw it, it was due to incorrect d...

Please Consult Before Posting: Unofficial FAQ Available #42
An unofficial FAQ for this newsgroup is available at http://umpmfaq.info. The source FAQ was last updated Saturday, November 20, 2004. You may save yourself and those willing to spend their time helping you both time and hassle by consulting this resource before posting what may already be a FAQ. The unofficial FAQ answers 157 of the most frequently asked questions in this newsgroup. Note that only a limited number of FAQ items have been added or modified for Money 2005--those that are derive from my limited experience with the product and on very high profile items in the newsgroup. If you ar...