A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How to add a new record to subform from main form?



 
 
Thread Tools Display Modes
  #1  
Old July 26th, 2004, 04:50 PM
Alex
external usenet poster
 
Posts: n/a
Default How to add a new record to subform from main form?

hi guys,

the subject line tell it all..
What is the code to add a new record to subform from the
main form?
The lines:

Me!frm_sub_ServiceAddresses.Form.NewRecord

DoCmd.GoToRecord acDataForm, Me!
frm_sub_ServiceAddresses.Form, acNewRec

do not work. Any suggestions?

Thank you.
  #2  
Old July 26th, 2004, 05:08 PM
tina
external usenet poster
 
Posts: n/a
Default How to add a new record to subform from main form?

first, make sure you're using the name of the subform control in the main
form. open the main form in design view, right click on the subform and
select Properties. click the Other tab and look at the Name property. use
that name in your code - in the main form - as follows:

With Me!MySubformControl.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

hth


"Alex" wrote in message
...
hi guys,

the subject line tell it all..
What is the code to add a new record to subform from the
main form?
The lines:

Me!frm_sub_ServiceAddresses.Form.NewRecord

DoCmd.GoToRecord acDataForm, Me!
frm_sub_ServiceAddresses.Form, acNewRec

do not work. Any suggestions?

Thank you.



  #3  
Old July 26th, 2004, 06:03 PM
Alex
external usenet poster
 
Posts: n/a
Default How to add a new record to subform from main form?

Hi Tina,

Unfortunately
this command just adds a new record to a main form's
recordsource.
What i need just add a new record to subform's
recordsource, with the slave field filled out
automatically from the master field of main form...

The problem is still there.
Thanks.
-----Original Message-----
first, make sure you're using the name of the subform

control in the main
form. open the main form in design view, right click on

the subform and
select Properties. click the Other tab and look at the

Name property. use
that name in your code - in the main form - as follows:

With Me!MySubformControl.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

hth





"Alex" wrote in

message
...
hi guys,

the subject line tell it all..
What is the code to add a new record to subform from

the
main form?
The lines:

Me!frm_sub_ServiceAddresses.Form.NewRecord

DoCmd.GoToRecord acDataForm, Me!
frm_sub_ServiceAddresses.Form, acNewRec

do not work. Any suggestions?

Thank you.



.

  #4  
Old July 26th, 2004, 08:41 PM
tina
external usenet poster
 
Posts: n/a
Default NOT SOLVED - MVPS PLS HELP? How to add a new record to subform from main form?

hmmm, i tested the solution, before posting, on A2003 in an A2k format db.
went to new record in the subform without a problem.
suggest you post more detail about when/where you're calling the code. also,
check your subform's AllowAdditions property, make sure it's set to Yes.


"Alex" wrote in message
...
Hi Tina,

Unfortunately
this command just adds a new record to a main form's
recordsource.
What i need just add a new record to subform's
recordsource, with the slave field filled out
automatically from the master field of main form...

The problem is still there.
Thanks.
-----Original Message-----
first, make sure you're using the name of the subform

control in the main
form. open the main form in design view, right click on

the subform and
select Properties. click the Other tab and look at the

Name property. use
that name in your code - in the main form - as follows:

With Me!MySubformControl.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

hth





"Alex" wrote in

message
...
hi guys,

the subject line tell it all..
What is the code to add a new record to subform from

the
main form?
The lines:

Me!frm_sub_ServiceAddresses.Form.NewRecord

DoCmd.GoToRecord acDataForm, Me!
frm_sub_ServiceAddresses.Form, acNewRec

do not work. Any suggestions?

Thank you.



.



  #5  
Old July 26th, 2004, 08:59 PM
Alex
external usenet poster
 
Posts: n/a
Default NOT SOLVED - MVPS PLS HELP? How to add a new record to subform from main form?

yes,
it adds a new record, but to main form.
Where i put the code:
on the button even click, button location - main form:
With Me!frm_sub_ServiceAddresses.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

There are main form - frm_Customers;
and subform - control's name - frm_sub_ServiceAddresses.

The Allow Additions property is set to Yes.


Tina, when you click on the button when you tested
it..what happens?
does the fields in the main form become blank?- this is
what happens in my case - new record to the form is
added..
the fields in the subform also become
blank..uderstandable.

Thanks for taking time to answer my question.

Alex

-----Original Message-----
hmmm, i tested the solution, before posting, on A2003 in

an A2k format db.
went to new record in the subform without a problem.
suggest you post more detail about when/where you're

calling the code. also,
check your subform's AllowAdditions property, make sure

it's set to Yes.


"Alex" wrote in

message
...
Hi Tina,

Unfortunately
this command just adds a new record to a main form's
recordsource.
What i need just add a new record to subform's
recordsource, with the slave field filled out
automatically from the master field of main form...

The problem is still there.
Thanks.
-----Original Message-----
first, make sure you're using the name of the subform

control in the main
form. open the main form in design view, right click

on
the subform and
select Properties. click the Other tab and look at the

Name property. use
that name in your code - in the main form - as

follows:

With Me!MySubformControl.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

hth





"Alex" wrote in

message
...
hi guys,

the subject line tell it all..
What is the code to add a new record to subform from

the
main form?
The lines:

Me!frm_sub_ServiceAddresses.Form.NewRecord

DoCmd.GoToRecord acDataForm, Me!
frm_sub_ServiceAddresses.Form, acNewRec

do not work. Any suggestions?

Thank you.


.



.

  #6  
Old July 27th, 2004, 12:24 AM
tina
external usenet poster
 
Posts: n/a
Default STILL NOT SOLVED - MVPS PLS HELP? How to add a new record to subform from main form?

when i click the button in my test form (in the main form) the subform jumps
to new (blank) record; the main form is not affected at all. i added a line
of code to set focus on the appropriate field in the subform, but that runs
*after* the new record code runs.
hopefully an MVP or some other smart person will solve this mystery for us.
g


"Alex" wrote in message
...
yes,
it adds a new record, but to main form.
Where i put the code:
on the button even click, button location - main form:
With Me!frm_sub_ServiceAddresses.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

There are main form - frm_Customers;
and subform - control's name - frm_sub_ServiceAddresses.

The Allow Additions property is set to Yes.


Tina, when you click on the button when you tested
it..what happens?
does the fields in the main form become blank?- this is
what happens in my case - new record to the form is
added..
the fields in the subform also become
blank..uderstandable.

Thanks for taking time to answer my question.

Alex

-----Original Message-----
hmmm, i tested the solution, before posting, on A2003 in

an A2k format db.
went to new record in the subform without a problem.
suggest you post more detail about when/where you're

calling the code. also,
check your subform's AllowAdditions property, make sure

it's set to Yes.


"Alex" wrote in

message
...
Hi Tina,

Unfortunately
this command just adds a new record to a main form's
recordsource.
What i need just add a new record to subform's
recordsource, with the slave field filled out
automatically from the master field of main form...

The problem is still there.
Thanks.
-----Original Message-----
first, make sure you're using the name of the subform
control in the main
form. open the main form in design view, right click

on
the subform and
select Properties. click the Other tab and look at the
Name property. use
that name in your code - in the main form - as

follows:

With Me!MySubformControl.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

hth




"Alex" wrote in
message
...
hi guys,

the subject line tell it all..
What is the code to add a new record to subform from
the
main form?
The lines:

Me!frm_sub_ServiceAddresses.Form.NewRecord

DoCmd.GoToRecord acDataForm, Me!
frm_sub_ServiceAddresses.Form, acNewRec

do not work. Any suggestions?

Thank you.


.



.



  #7  
Old July 27th, 2004, 02:25 PM
Dirk Goldgar
external usenet poster
 
Posts: n/a
Default How to add a new record to subform from main form?

"Alex" wrote in message

Hi Tina,

Unfortunately
this command just adds a new record to a main form's
recordsource.
What i need just add a new record to subform's
recordsource, with the slave field filled out
automatically from the master field of main form...

The problem is still there.
Thanks.
-----Original Message-----
first, make sure you're using the name of the subform control in the
main form. open the main form in design view, right click on the
subform and select Properties. click the Other tab and look at the
Name property. use that name in your code - in the main form - as
follows:

With Me!MySubformControl.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

hth





"Alex" wrote in message
...
hi guys,

the subject line tell it all..
What is the code to add a new record to subform from the
main form?
The lines:

Me!frm_sub_ServiceAddresses.Form.NewRecord

DoCmd.GoToRecord acDataForm, Me!
frm_sub_ServiceAddresses.Form, acNewRec

do not work. Any suggestions?


Assuming the subform in question is only one level deep -- that is, it
is a child of a main form, not a child of a subform -- you should be
able to do it by setting the focus to the subform control, then telling
Access to go to a new record on the "active data object":

Me!frm_sub_ServiceAddresses.SetFocus
DoCmd.GoToRecord acActiveDataObject, ,acNewRec

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #8  
Old July 27th, 2004, 04:23 PM
Alex
external usenet poster
 
Posts: n/a
Default How to add a new record to subform from main form?

Yes, it worked. Thanks.


-----Original Message-----
"Alex" wrote in

message

Hi Tina,

Unfortunately
this command just adds a new record to a main form's
recordsource.
What i need just add a new record to subform's
recordsource, with the slave field filled out
automatically from the master field of main form...

The problem is still there.
Thanks.
-----Original Message-----
first, make sure you're using the name of the subform

control in the
main form. open the main form in design view, right

click on the
subform and select Properties. click the Other tab

and look at the
Name property. use that name in your code - in the

main form - as
follows:

With Me!MySubformControl.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

hth





"Alex" wrote in

message
...
hi guys,

the subject line tell it all..
What is the code to add a new record to subform from

the
main form?
The lines:

Me!frm_sub_ServiceAddresses.Form.NewRecord

DoCmd.GoToRecord acDataForm, Me!
frm_sub_ServiceAddresses.Form, acNewRec

do not work. Any suggestions?


Assuming the subform in question is only one level deep -

- that is, it
is a child of a main form, not a child of a subform --

you should be
able to do it by setting the focus to the subform

control, then telling
Access to go to a new record on the "active data object":

Me!frm_sub_ServiceAddresses.SetFocus
DoCmd.GoToRecord acActiveDataObject, ,acNewRec

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.

  #9  
Old July 27th, 2004, 04:44 PM
tina
external usenet poster
 
Posts: n/a
Default How to add a new record to subform from main form?

cool, another "trick" to put up my sleeve!


"Dirk Goldgar" wrote in message
...
"Alex" wrote in message

Hi Tina,

Unfortunately
this command just adds a new record to a main form's
recordsource.
What i need just add a new record to subform's
recordsource, with the slave field filled out
automatically from the master field of main form...

The problem is still there.
Thanks.
-----Original Message-----
first, make sure you're using the name of the subform control in the
main form. open the main form in design view, right click on the
subform and select Properties. click the Other tab and look at the
Name property. use that name in your code - in the main form - as
follows:

With Me!MySubformControl.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

hth





"Alex" wrote in message
...
hi guys,

the subject line tell it all..
What is the code to add a new record to subform from the
main form?
The lines:

Me!frm_sub_ServiceAddresses.Form.NewRecord

DoCmd.GoToRecord acDataForm, Me!
frm_sub_ServiceAddresses.Form, acNewRec

do not work. Any suggestions?


Assuming the subform in question is only one level deep -- that is, it
is a child of a main form, not a child of a subform -- you should be
able to do it by setting the focus to the subform control, then telling
Access to go to a new record on the "active data object":

Me!frm_sub_ServiceAddresses.SetFocus
DoCmd.GoToRecord acActiveDataObject, ,acNewRec

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Open form, Edit button, etc Aniko Using Forms 14 July 25th, 2004 08:17 AM
How can I move the focus to a control on a subform? Brandon General Discussion 7 July 17th, 2004 01:39 AM
Recordset in subform based on field in parent form Lyn General Discussion 15 June 14th, 2004 03:10 PM
Controls on Main form affecting subform? Will Setting Up & Running Reports 1 May 27th, 2004 07:37 PM
synchronization of subform to main form Charles Phillips Using Forms 1 May 26th, 2004 12:50 AM


All times are GMT +1. The time now is 11:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.