Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
New blank record on a subform
Colin Smyth 
      
2 years ago
I have a database as per the attached photo. The data on the blue form is personal details which usually doesn't change. The subform in the green may have multiple visits for the attached person. I know I can make a blank form in the subform by clicking the section on the bottom of the record bar but I would rather have a button or something to make the subform blank. I thought the code below would work but it doesn't

DoCmd.GoToRecord acDataForm, "AddAssistanceDatF", acNewRec

Any suggestions please.
Colin Smyth OP  @Reply  
      
2 years ago

Kevin Robertson  @Reply  
          
2 years ago
Try this:

    Dim mySubform As Object
    Set mySubform = Parent!AddAssistanceDatF.Form

    mySubform.Recordset.AddNew
Colin Smyth OP  @Reply  
      
2 years ago
Thank you Kevin. That didn't seem to work. VBA editor didn't like the second line. Also was this supposed to be added to on load or could it be used as on click of the New Record Button on the form
Kevin Robertson  @Reply  
          
2 years ago
Check the name of your Subform object.
Put the code in the Click event of your Button.
Colin Smyth OP  @Reply  
      
2 years ago
Hi Kevin. I spelt the form name incorrectly first time - should be AddAssistance.dataF. Having corrected this, I now get the following error - see photo. Not sure what field it is supposedly looking for. I am not great with VBA as you can tell - where you had parent, do I leave it as that or should it be the parent form name. Thanks again
Colin Smyth OP  @Reply  
      
2 years ago

Kevin Robertson  @Reply  
          
2 years ago
Go to the properties of the Subform object (not the Form). Is it named AddAssistanceDataF?
Post a screenshot of the Property Sheet showing the Name property. I tested the code in my own database and it definitely works.
Colin Smyth OP  @Reply  
      
2 years ago
I think this is what you requested
Colin Smyth OP  @Reply  
      
2 years ago

Kevin Robertson  @Reply  
          
2 years ago
The name is Assistance Given.
You will either need to remove the space or enclose in square brackets.

Set mySubform = Parent![Assistance Given].Form
Colin Smyth OP  @Reply  
      
2 years ago
I want to sincerely thank you Kevin for your patience and your assistance. It now works perfectly. Really appreciate your help.
Kevin Robertson  @Reply  
          
2 years ago
You're welcome.

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

Next Unseen

 
New Feature: Comment Live View
 
 

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: 5/6/2026 11:24:19 AM. PLT: 0s