Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images | @Reply | Bookmark | Link | Email | Next Unseen |
Deleting a Record on Closing
Darren McMartin 
    
2 years ago
I have a button on a form that opens up a related record. Even if I don't add any data, a record is created because the form opened. I would like to remove that record when the form is closed, as the table only contains the primary key and foreign key and all other fields are empty.
Sami Shamma  @Reply  
             
2 years ago
This is not normal Access behavior. What is your button code?
Kevin Robertson  @Reply  
          
2 years ago
If a record is being created you must be setting a value on the form. Set it as a default value instead and a record won't be created.

Example:
MyField.DefaultValue = Value
Darren McMartin OP  @Reply  
    
2 years ago
Hi Kevin,
I had PersonF form opened. I then clicked a button on it to open CardF form. They are linked by PersonID. When values are added to the CardF, a record in CardT is created. The problem was when I decided not to put values into the CardF, and closed it, a record was still being created in the CardT as a it had recorded the PersonID.

I had set the default value for PersonID (the Foreign Key) in CardT = Forms![PersonF]!PersonID.

After seeing what you wrote, I made the following change:

I have now changed it to = if([CardFront]=Null Or [CardFront]="",Null,[Forms]![PersonF]![PersonID]).

It seems to have solved the problem.

Thanks.
Darren McMartin OP  @Reply  
    
2 years ago
I rechecked what I did, and my solution didn't fix my problem. What seems to have fixed it is I placed a file in the directory I was referencing, and it stopped the problem.
Richard Rost  @Reply  
           
2 years ago
I recommend using default values if possible, as Kevin suggested.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
 
What's This?

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 11/15/2026 7:44:45 AM. PLT: 1s