473,395 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Is acCmdDeleteRecord available for a subform's subform?

I have a form with a subform (normal) that itself has a subform (datasheet).

I can't get a delete command button to work with the following code. It says
"delete not available now". Any suggestions?
'************************************************* ****************
Public Function DeleteRecord()

Dim frm As Form, subfrm As Form

Set frm = Forms!frmA!Subfrm1.Form
Set subfrm = frm!Subfrm2.Form

frm!Subfrm2.SetFocus

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

End Function
'************************************************* ****************
Nov 12 '05 #1
2 8025
Setting focus on a control in a subform from the main form is a two step
process: first set the focus on the subform control then set the focus on the
control. This rule applies in your case because Subfrm2 is a control on Subfrm1
and FrmA is the main form. (Assuming that Subfrm1 and Subfrm2 are both names of
subforms and also the names of the subform controls that hold the subforms)
Also, once you set focus on a subform control, executing DoCmd.RunCommand
acCmdDeleteRecord will delete the current record in the subform. So you need the
following code:

Public Function DeleteRecord()
Forms!frmA!Subfrm1.SetFocus
Forms!frmA!Subfrm1.Form!Subfrm2.SetFocus
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
End Function
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"Mark B" <remove_from _h*********************@ihug.co.nz> wrote in message
news:bq**********@lust.ihug.co.nz...
I have a form with a subform (normal) that itself has a subform (datasheet).

I can't get a delete command button to work with the following code. It says
"delete not available now". Any suggestions?
'************************************************* ****************
Public Function DeleteRecord()

Dim frm As Form, subfrm As Form

Set frm = Forms!frmA!Subfrm1.Form
Set subfrm = frm!Subfrm2.Form

frm!Subfrm2.SetFocus

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

End Function
'************************************************* ****************

Nov 12 '05 #2
Thanks. I had just spent the last hour enforcing my will in a rough way. It
worked ..... but no one wants SendKeys including me. Plus it flickered
navigation mode changes on the screen. Thanks for posting an answer.

Subfrm.ActiveControl.SelLength = subfrm.ActiveControl.SelStart
'Switch to Edit Mode
SendKeys "{F2}", True
'Switch to Navigation Mode
SendKeys "+{ }", True
'Select Row
SendKeys "{DEL}", True
'Delete Row
Mark

"PC Datasheet" <sp**@nospam.spam> wrote in message
news:zI*******************@newsread2.news.atl.eart hlink.net...
Setting focus on a control in a subform from the main form is a two step
process: first set the focus on the subform control then set the focus on the control. This rule applies in your case because Subfrm2 is a control on Subfrm1 and FrmA is the main form. (Assuming that Subfrm1 and Subfrm2 are both names of subforms and also the names of the subform controls that hold the subforms) Also, once you set focus on a subform control, executing DoCmd.RunCommand
acCmdDeleteRecord will delete the current record in the subform. So you need the following code:

Public Function DeleteRecord()
Forms!frmA!Subfrm1.SetFocus
Forms!frmA!Subfrm1.Form!Subfrm2.SetFocus
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
End Function
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"Mark B" <remove_from _h*********************@ihug.co.nz> wrote in message
news:bq**********@lust.ihug.co.nz...
I have a form with a subform (normal) that itself has a subform (datasheet).
I can't get a delete command button to work with the following code. It says "delete not available now". Any suggestions?
'************************************************* ****************
Public Function DeleteRecord()

Dim frm As Form, subfrm As Form

Set frm = Forms!frmA!Subfrm1.Form
Set subfrm = frm!Subfrm2.Form

frm!Subfrm2.SetFocus

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

End Function
'************************************************* ****************


Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that...
1
by: edself | last post by:
I have created a form with a subform that displays the results of a query in datasheet view. I'd like to be able to expand subdatasheets for each record listed in the subform datasheet. The...
5
by: deko | last post by:
After developing an MDB in Access 2003 on WS03, then making it into an MDE and deploying it on a WinXP box with Access 2003 installed, I get this error: Function is not available in expressions...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
1
by: Omar Anwar | last post by:
Hi. I am using form and subform in which form has combo boxes that sets the criteria for the query. i am using grouping in the select query and the contents of the query are displayed in the...
6
by: DMUM via AccessMonster.com | last post by:
Hello I am trying to pass the name of my subform to a function/sub but I can't seem to get it to work. I am using an autokey function (ctrl E) to unlock text boxes on a subform. I have a few...
2
by: Wayne | last post by:
I've noticed a behaviour in A2007 that doesn't appear in A2003. The problem is appearing in a native A2007 database and an A2003 database running in A2007. If I press a command button to delete a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.