Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to ACCDE    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Changing form recordsource
Simon Levesque 
     
3 years ago
I have a code working just fine in accdb file that opens a form in design view, change its record source, save it and open the form in normal view, all this on a click button event. Now, in accde file, this code doesnt work anymore. How to fix this
Kevin Robertson  @Reply  
          
3 years ago
A form cannot be opened in Design View in an ACCDE file. Is there a reason why you need to open the form in Design View?
Simon Levesque OP  @Reply  
     
3 years ago
To change its record source because a table is created by code and now, the user must fill this table with this template form so each time the user open the form, its a different table as record source depending on the user choice
Kevin Robertson  @Reply  
          
3 years ago
You don't need to switch to Design View to set the Record Source.

Me.RecordSource = "TableName"

Me.RecordSource = "QueryName"

Me.RecordSource = "SQL Statement"
Simon Levesque OP  @Reply  
     
3 years ago
Ill try it again but it doesn't seem to work when Im in the Accde file. My code is in a click button event to open this template form. Does it matter if the form is open or close to execute this code(me.recordsource)
Kevin Robertson  @Reply  
          
3 years ago
I you're opening the Form with a button on a different Form you have to specify the name of the form you want to set the Record Source for.

Example:
DoCmd.OpenForm "TemplateF"
Forms!TemplateF.RecordSource = "CustomerT"


Value From a Form
Simon Levesque OP  @Reply  
     
3 years ago
I tried the code you provided and it doesn't work, even in the regular accdb file. You can see my original code preceded by '. This code with design view is working perfectly in the accdb file but not in accde, Im confused! (the name of the table is in a hidden field (NomTabOp)in the form containing the button for this code)
    DoCmd.OpenForm ("Entrees_F")
    'DoCmd.RunCommand acCmdDesignView
     Forms!Entrees_F.RecordSource = Me.NomTabOp
    'DoCmd.Save
    'DoCmd.RunCommand acCmdFormView
Kevin Yip  @Reply  
     
3 years ago
Hi Simon, what exactly doesn't work?  Changing the recordsource in design view is the only way to save the recordsource into the form permanently, while changing the RecordSource property with VBA as Kevin suggested does not save it into the form -- when you reopen the form, the old recordsource remains.  Is that what you mean by doesn't work?
Simon Levesque OP  @Reply  
     
3 years ago
Thank you all for your help. I was expecting the same behaviour as my original code so it would change the recordsource in the form property sheet. I was working with blank tables as recordsource so I wasn't seeing that it was working because each time I looked in the property sheet, it was the original record source, so problem solved. Thanks!

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

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: 4/30/2026 11:45:36 AM. PLT: 1s