HI,
When a new record is opened in a main form / sub form, how do I prevent the main form from saving data if the sub form is not filled? Or how do I delete the current main form record if the sub form is not filled?
7 3275
HI,
When a new record is opened in a main form / sub form, how do I prevent the main form from saving data if the sub form is not filled? Or how do I delete the current main form record if the sub form is not filled?
You can't prevent the main form from saving data because there needs to be an existing main record for a sub record. You could have the form delete the offending records when it closes though.
You can't prevent the main form from saving data because there needs to be an existing main record for a sub record. You could have the form delete the offending records when it closes though.
What is the code/procedure for deleting the offending records? I've searched (googled my googler to death), but all I find is info on delete object or a delete queries which seem to be to broad.
Thanks for responding.
What is the code/procedure for deleting the offending records? I've searched (googled my googler to death), but all I find is info on delete object or a delete queries which seem to be to broad.
Thanks for responding.
Not much code. Just set up the delete query with a subquery condition and then use DoCmd.OpenQuery.
Not much code. Just set up the delete query with a subquery condition and then use DoCmd.OpenQuery.
Thanks!
Not to be pushy but... how do I word the the subquery so it will delete the "selected current" record? Also, I have the problem where when I do try to delete a record from the main form (using the archaic click on the edit menu and delete) it won't let me because I have a related record in another table (the sub form table). So I would have to delete related records as well. Sorry, I usually just search and search until I find code/explanation/criteria that will work for my application. I'm not to hot at putting the language together from scratch. Kind of stuck learning as I go... know any great books on access/vb/vba? = )
Thanks!
Not to be pushy but... how do I word the the subquery so it will delete the "selected current" record? Also, I have the problem where when I do try to delete a record from the main form (using the archaic click on the edit menu and delete) it won't let me because I have a related record in another table (the sub form table). So I would have to delete related records as well. Sorry, I usually just search and search until I find code/explanation/criteria that will work for my application. I'm not to hot at putting the language together from scratch. Kind of stuck learning as I go... know any great books on access/vb/vba? = )
You don't word it to delete selected record. You have it do a one-time delete when the form closes and delete everything that doesn't have a subform record.
If you set up the relationships with the Enforce Relationship and Cascade delete checked, you won't have to go through that process. But you don't want to delete that record anyways right? It has a subform record, you only want to delete the ones without a subform record.
I don't know any books, i learned as I went as well.
You don't word it to delete selected record. You have it do a one-time delete when the form closes and delete everything that doesn't have a subform record.
If you set up the relationships with the Enforce Relationship and Cascade delete checked, you won't have to go through that process. But you don't want to delete that record anyways right? It has a subform record, you only want to delete the ones without a subform record.
I don't know any books, i learned as I went as well.
OK, I'll give it a go. Thanks Rabbit, and your right... I don't want the sub form records zapped. Just wondered how it's done.
Good luck, let us know if you have any trouble.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Robert Schneider |
last post by:
Hi to all,
I don't understand that: I try to delete a record via JDBC. But I always
get the error SQL7008 with the error code 3. It seems that this has
something to do with journaling, since the...
|
by: Steve |
last post by:
I have several pairs of synchronized subforms in an application. I have a Delete
button for each pair that uses the following code or similar to delete a record
in the second subform:
...
|
by: perryche |
last post by:
I have 5records, e.g. Rc1, Rc2, Rc3..., when user open up a form, I
want it to open to a particular record (say Rc3) then when user chooses
the Record Selector , it will go to Rc2 and , it will go...
|
by: polocar |
last post by:
Hi,
I'm writing a program in Visual C# 2005 Professional Edition.
This program connects to a SQL Server 2005 database called
"Generations" (in which there is only one table, called...
|
by: (PeteCresswell) |
last post by:
I've got apps where you *really* wouldn't want to delete certain items by
accident, but the users just have to have a "Delete" button.
My current strategies:
Plan A:...
|
by: Bob Bridges |
last post by:
Start with two tables, parent records in one and child records in the other,
a one-to-many relationship. Create a select statement joining the two.
Display the query in datasheet mode. When I...
|
by: Steven |
last post by:
Hi,
Would need some thought about using a button of the existing form to search
record before deleting it.
Any quick help is very appreciated.
Steve
|
by: brucedodds |
last post by:
My application has a form based on a parent table with a subform based
on a child table. The relationship is Cascade Delete. The first
record displayed when the form opens has five child records....
|
by: beacon |
last post by:
Hi everybody,
This is probably going to sound unorthodox, but I have to log records that are deleted...I know, go figure.
Anyway, I have a form with a (continuous) subform, and on the subform I...
|
by: matthewslyman |
last post by:
I have an unusual design and some very unusual issues with my code... I have forced Access to cooperate on everything except one issue - record deletion.
My form design involves a recursively...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |