473,406 Members | 2,273 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,406 software developers and data experts.

How do I delete a record on a subform?

Seth Schrock
2,965 Expert 2GB
I need to know how to use a For Each/Next loop to delete all records on a subform that have the same values in a field. The subform is a form based on a linking table with both fields combined as the primary key and the field that hold the criteria is the same as the primary key of the main form (I hope that makes sense). I have tried making the field null using the Form!MainForm!SubForm.Form!Control.Value = null for both fields, but it just deletes the first record and then when I leave it, it says I can't leave the primary key field blank. So I think that I have to delete the record.

The fields in the subform are KeyFobSN and BranchNumber. The subform is linked to the main form by the KeyFobSN. Each KeyFob will have many records as each has access to many branches.
May 23 '11 #1

✓ answered by NeoPa

Deleting matching records would not typically done via the form interface at all, nor would it be done using a VBA For/Next structure. The way to accomplish this most straightforwardly would be to create and use a SQL DELETE query.

I guess from the question it would help to point out that records are never stored on or in forms. They are merely shown via the form object as if using a window.

Perhaps with that in mind you could restate the question in a way that makes more sense logically (if you still need to with your new understanding).

6 2412
NeoPa
32,556 Expert Mod 16PB
Deleting matching records would not typically done via the form interface at all, nor would it be done using a VBA For/Next structure. The way to accomplish this most straightforwardly would be to create and use a SQL DELETE query.

I guess from the question it would help to point out that records are never stored on or in forms. They are merely shown via the form object as if using a window.

Perhaps with that in mind you could restate the question in a way that makes more sense logically (if you still need to with your new understanding).
May 24 '11 #2
Seth Schrock
2,965 Expert 2GB
I'll look into the sql delete query.

I am aware that the records are stored in the tables and not in the forms. I just said it that way because that is the way that I see the information.
May 25 '11 #3
NeoPa
32,556 Expert Mod 16PB
Seth Schrok:
I am aware that the records are stored in the tables and not in the forms. I just said it that way because that is the way that I see the information.
I expect a little thought will tell you to avoid that approach in future then.

It's hard to phrase a question that makes sense within a concept that doesn't, and we generally prefer dealing with questions that make sense.
May 25 '11 #4
Seth Schrock
2,965 Expert 2GB
The delete query works perfectly. Thank you so much.
May 25 '11 #5
Seth Schrock
2,965 Expert 2GB
I was having trouble wording my question without making it be a 10 page paper. I will keep that in mind next time I have a question. Thanks for the tip.
May 25 '11 #6
NeoPa
32,556 Expert Mod 16PB
I do appreciate that Seth :-) Phrasing a question so that it's clear and understandable is actually much harder than it looks. Especially within a technical area such as this.

It may be encouraging to know though, that many people report that having taken the trouble to think it through themselves (in order to express it clearly for the thread), they often don't need to ask it any more. Not universally of course, but it shows it can help the questioner too, as well as those willing to help.

Anyway, I'm very glad the tip of using SQL for this has helped. Good luck with your project.
May 25 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: bher2 | last post by:
please help i was trying to delete a specific record on a table but it still shows the same record that should be deleted. i dont know how.
3
by: Uwe Range | last post by:
Hi to all, I am displaying a list of records in a subform which is embedded in a popup main form (in order to ensure that users close the form when leaving it). It seems to be impossible to...
2
by: Ian Hinson | last post by:
Hi, I have a subform in a form in an ADP that I am creating "form-by-form" based on an equivalent MDB front-end db. (I'm converting from a front-end/back-end mdb structure to an AccessXP ADP +...
2
by: LostBoy | last post by:
Hello, I have created a subform/report on a form based on a table. I would like to be able to delete the accounts if necessary. I thought creating a delete button using the wizard would work but...
3
by: igendreau | last post by:
I'm trying to clean up a database of mine, and I need to convert some old DAO code over to ADO. When I was using DAO, I had no problem running this script and deleting the record using rs.Delete. ...
4
by: Craggy | last post by:
Hi, I am trying to pop up a yes/no message box so that a user can delete a record in a continuous form. The default delete message is a bit sloppy because it seems to move the continuous form to...
3
by: Phil Stanton | last post by:
I have a form based on a complex query (Lots of tables) If I delete a record, everything appears to be OK. Get the message "Youa are about to delete 1 record ....". I say yes. The record count...
4
by: barkarlo | last post by:
I use check box in a form "frmworkorder" like confirmation that's record finish. How can I write code who will block edit and delete record in form when is check box confirmed.
1
by: CreativeMind | last post by:
hi all, private void dgMygrid_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { Button bDelete=(Button)e.Item.FindControl("btnDelete"); if(bDelete!=null) {...
3
mseo
by: mseo | last post by:
hi, I need to delete the record in form and all the related record from the subform I don't know how to do so. thanks
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.