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
> Go To New Record On Continuous Subform, Access 2016    
 
   
dashiellx2000
post Feb 12 2019, 01:12 PM
Post#1


UtterAccess VIP
Posts: 9,826
Joined: 11-March 05
From: Maryland


I have a form with subform that shows email address associated with a contact.
On the form's Current event, if the main form's record is not a new record, the subform's allow additions property is set to false. On the main form I have a button to add an email address. What I want to have happen on the button click is for the subform's allow additions property to be updated to True, set the focus on the subform and the correct subform control on the new record line. I cannot seem to get the code to goto the new record. Here is what I have:

CODE
Private Sub cmdAddEmail_Click()
Me.Dirty = False
Me.sfrmContactEmailAddresses.Form.AllowAdditions = True
Me.sfrmContactEmailAddresses.SetFocus
Me.sfrmContactEmailAddresses!txtEmail.SetFocus
End Sub


I have tried everything I can find to move to the new record, but either I get an error saying the subform isn't open or nothing happens.

thanks.

--------------------
William
“We're run by the Pentagon, we're run by Madison Avenue, we're run by television, and as long as we accept those things and don't revolt we'll have to go along with the stream to the eventual avalanche"
Go to the top of the page
 
theDBguy
post Feb 12 2019, 01:15 PM
Post#2


Access Wiki and Forums Moderator
Posts: 74,985
Joined: 19-June 07
From: SunnySandyEggo


Hi William. Have you tried it this way?

Me.sfrmContactEmailAddresses.Form!txtEmail.SetFocus

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
tina t
post Feb 12 2019, 01:32 PM
Post#3



Posts: 5,868
Joined: 11-November 10
From: SoCal, USA


to go to a new subform record, i've had success with the following, as

CODE
Me.sfrmContactEmailAddresses.SetFocus

With Me.sfrmContactEmailAddresses.Form
    DoCmd.RunCommand acCmdRecordsGoToNew
End With

hth
tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 
dashiellx2000
post Feb 12 2019, 01:45 PM
Post#4


UtterAccess VIP
Posts: 9,826
Joined: 11-March 05
From: Maryland


QUOTE
Hi William. Have you tried it this way?

Me.sfrmContactEmailAddresses.Form!txtEmail.SetFocus


With my current code, the focus is going to the correct control on the subform, not on the new record, but the first record. When I make your suggestion change I get the same results.

QUOTE
to go to a new subform record, i've had success with the following, as

CODE
Me.sfrmContactEmailAddresses.SetFocus

With Me.sfrmContactEmailAddresses.Form
    DoCmd.RunCommand acCmdRecordsGoToNew
End With

hth
tina


Thank you, but I'm getting the same result with this as well.


--------------------
William
“We're run by the Pentagon, we're run by Madison Avenue, we're run by television, and as long as we accept those things and don't revolt we'll have to go along with the stream to the eventual avalanche"
Go to the top of the page
 
theDBguy
post Feb 12 2019, 01:48 PM
Post#5


Access Wiki and Forums Moderator
Posts: 74,985
Joined: 19-June 07
From: SunnySandyEggo


Ah, yes. SetFocus only goes to the control. To go to a new record, you could also try it this way.

Me.SubformControlName.SetFocus
DoCmd.GoToRecord , , acNewRec

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
tina t
post Feb 12 2019, 01:51 PM
Post#6



Posts: 5,868
Joined: 11-November 10
From: SoCal, USA


hmm, okay. first, what is the name of the container control on the mainform, that "houses" the subform? it can be the same name as the subform form object, or it can be different. to get the name, open the mainform in Design view, click once on the subform to select the container control, and look at the Name property in the Properties list.

make sure that's the name you're using in the code to refer to the subform.

next, try running just the line of code that set's the subform's AllowAdditions property to True. then scroll down in the subform. is there in fact a new (blank) record available at the bottom of the ContinuousForm?

hth
tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    23rd April 2019 - 05:09 AM