UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Creating A New Record In A Subform Of A Subform (new Post), Access 2016    
 
   
tbaker818
post Jan 11 2017, 04:52 PM
Post#1



Posts: 145
Joined: 3-April 09
From: SoCal, USA


I know I've done this before, but nothing I've tried is working this time. I've attached a sample of what I'm trying to do. The form opens automatically and there's a Populate button which illustrates the problem I'm having. No matter what I do, Access creates a new record in the main form, never the subform. You can see in the code in the form's module with the different methods I've tried.
Attached File(s)
Attached File  Sample.zip ( 211.08K )Number of downloads: 7
 
Go to the top of the page
 
tbaker818
post Jan 12 2017, 12:48 PM
Post#2



Posts: 145
Joined: 3-April 09
From: SoCal, USA


I'm sure this is an easy fix, basically - how do I direct VBA to the subform for creating a new record? I've tried the solutions suggested online, but they're not working.
Go to the top of the page
 
missinglinq
post Jan 12 2017, 01:04 PM
Post#3



Posts: 4,224
Joined: 11-November 02



You have to move focus to the Subform Control first, then move to a New Record:

SubFormControlName.SetFocus
DoCmd.GoToRecord , , acNewRec

Linq ;0)>

--------------------
Hope this helps!

The problem with making anything foolproof...is that fools are so darn ingenious!

All posts/responses based on Access 2003/2007
Go to the top of the page
 
tbaker818
post Jan 12 2017, 01:15 PM
Post#4



Posts: 145
Joined: 3-April 09
From: SoCal, USA


Yes, this is actually the first thing I tried. Like this in my case:

CODE
Me.frmTables.Form.Controls("frmColumns").SetFocus
DoCmd.GoToRecord , , acNewRec


The other method is to use the following code in the subform class module Form_Columns:
CODE
Sub GoToNewRecord()
    DoCmd.GoToRecord , , acNewRec
End Sub


And then call it from the main form like so:
CODE
Form_Columns.GoToNewRecord


Both of these result in a new record being created in the main form only, although sometimes it will somehow act on the Tables subform one level up instead. Never the Columns subform I'm trying to work with.
Go to the top of the page
 
missinglinq
post Jan 12 2017, 07:06 PM
Post#5



Posts: 4,224
Joined: 11-November 02



No, what you tried

CODE
Me.frmTables.Form.Controls("frmColumns").SetFocus
DoCmd.GoToRecord , , acNewRec


is not what I gave you! I gave you

CODE
[b]SubFormControlName.SetFocus
DoCmd.GoToRecord , , acNewRec[/b]


Where SubFormControlName is just that...the name of the Subform Control that holds the Form you want a new record on! It may or may not be the same name as the Form's name, depending on how the Subform was created.

--------------------
Hope this helps!

The problem with making anything foolproof...is that fools are so darn ingenious!

All posts/responses based on Access 2003/2007
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    19th January 2017 - 07:57 AM