473,480 Members | 2,347 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A2K - create new record in subform from main form

Thanks for the replies to my previous post. So while I'm on a roll
here's another plea for help.

I simply need the code for a button on the main form that will create a
new record in the subform. Hopefully this will always force the new
row to be selected (i.e it scrolls to the bottom if needed).

Extensive googling has given me many threads and the clearest answer
seems to be set focus to the subform and then create the record;

Forms!frmStaff!frmDetails_subform.Form.Date.SetFoc us
DoCmd.GoToRecord , , acNewRec

This simply creates a new parent record and the control doesn't get the
focus.

Any help?

Thanks
Martin
Nov 13 '05 #1
2 2948
Deano wrote:
Thanks for the replies to my previous post. So while I'm on a roll
here's another plea for help.

I simply need the code for a button on the main form that will create a
new record in the subform. Hopefully this will always force the new
row to be selected (i.e it scrolls to the bottom if needed).

Extensive googling has given me many threads and the clearest answer
seems to be set focus to the subform and then create the record;

Forms!frmStaff!frmDetails_subform.Form.Date.SetFoc us
DoCmd.GoToRecord , , acNewRec

This simply creates a new parent record and the control doesn't get the
focus.

Any help?

Thanks
Martin


See if this gets you close. I created a button on the main form with
the name CommandNewSubFormRec. SubFormName is the name of the
subform....change it to your subform name.

Private Sub CommandNewSubFormRec_Click()
Me.SubformName.SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNewRec
End Sub
Nov 13 '05 #2
Salad wrote:
Me.SubformName.SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNewRec


Salad, I love you man. That works!
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
8340
by: Carl | last post by:
I have a main form with navigation buttons on it and a label showing for example Record 1 of 15 using recordsetclone on it and eveything works fine. When I move through the records the record...
7
11164
by: ChrisR | last post by:
Hi guys My app is a simple Main form with a few Subforms that are not linked, and a few pop forms. Problem is: I have a pop form with a Listbox with a list of records related to the...
6
3929
by: Steve | last post by:
I have a form, primary subform and secondary subform. A tab control takes up all the area of the primary subform. There are about 15 tabs on the tabcontrol. Each tab contains fields from the same...
1
1545
by: amywolfie | last post by:
Whenever a record is modified on frmMain, I want the Event(AfterUpdate) to ADD a new record to frmRevisionHistory and goto this form. I also need to Set the FK_ID field of frmRevisionHistory to...
1
2215
by: dee | last post by:
I have a main form "FmLeads". It contains a field "Salesman" which has an 'After Change' Event Procedure. The Main form "FmLeads", contains a subform "FmDispoHistory". It displays all historic...
7
3388
by: FNA access | last post by:
I have a mainform that has a subform in the detail section and a subform in the footer section.(Both subforms are in datasheet view) When I click the navigation button to create a new record on the...
2
4323
by: gavm360 | last post by:
Hello, I have a data entry form that has a button to copy the values of fields (CASECODE,STEPDES,CBOANSWER) into the fields (CASECODE,STEPDES,ANSWER) of a subform on the page. Private Sub...
4
1923
by: banderson | last post by:
Hello, I am having a problem getting a new record in a subform to append to the underlying table. When I add a new record to the main form, the subform is blank, except for the ID field, which is...
0
2356
by: TD | last post by:
I have a main form with two subforms (both in datasheet view), neither of which are linked to the main form. The main form is based on a query that uses the bound column of a combobox on the main...
0
7051
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7054
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6750
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4794
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3003
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1307
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
567
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.