473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

New record in subForm on mainForm load

I have a Starting form ("frmStart") and a main form ("frmCustomer")
inside frmCustomer are two subform, one with it's own subform. So
frmCustomer has two subforms ("sbfArtist" and "sbfAddress") inside
subform "sbfArtist" is another subform, "sbfTitle"... I'll try to
create a visible heiarchy:

frmStart
----frmCustomer
--------sbfAddress
--------sbfArtist
------------sbfTitle

I hope that helps set up the picture...

Anyway, inside frmStart is a command button that allows the user to
enter a new Address in frmCustomer. The CustomerID is readily available
form frmStart. I don't want to do this with SQL code as I need the
ability to allow the user to back out of creating a new entry and to
edit the fields before it's updated. Inside frmCustomer_Load() I tried
using RunCommand acCmdRecordsGoToNew after setting the focus to the
subform but that did not work.

I load and display the correct CustomerID with:

Private Sub Form_Load() ' frmCustomer
If Me.OpenArgs = "NewBillAddress" Then
With Me.RecordsetClone
.FindFirst "[CustomerID]=" & Forms!frmStart!Customer
If Not .NoMatch Then
Me.Bookmark = .Bookmark
With Me.[sbfAddress].Form
Me.sbfAddress.Form.SetFocus
Me.sbfAddress.Form.addNewRecord
End With
End If
End With
End If
End Sub

That executes without error but fails to set focus to a New record in
sbfAddress

After getting this to work I will attempt to create similar
functionality to the 2-level-subform (frmCustomer>>sbfArtist>>sbfTitle)
and I'm sure I can figure that out if I can just get this to work.

Any help would be greatly appreciated. Thanks!

Aug 9 '06 #1
1 5442
I have figured it out, this is how I did it:

In the button on frmStart to open the frmCustomer and enter a new
address is this code:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmCustomer", , , _
  2. "CustomerID=" & Me!Customer, acFormEdit, acDialog, "NewAddress"
  3. Me![BillAddress].Requery
  4.  
on the Form_Load event of frmCustomer is the following:
Expand|Select|Wrap|Line Numbers
  1. '  ... select statement handling the OpenArgs ...
  2. Me.sbfAddress.SetFocus
  3. DoCmd.GoToRecord , , acNewRec
  4. '  ... end select
  5.  
That works like a charm. Now, for doing the same to sbfTitle, which is
a subform of sbfArtist ... the key is to set focus to the 'parent'
subform and then set the focus to the 'child' subform and go to
a new record, here is the code for those interested (this goes in the
Form_Load event):

Expand|Select|Wrap|Line Numbers
  1. ' ... select statement ...
  2. Me.sbfArtist.SetFocus
  3. Me!sbfArtist.Form!sbfTitle.SetFocus
  4. DoCmd.GoToRecord , , acNewRec
  5. ' ... end select
  6.  
Aug 11 '06 #2

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

Similar topics

0
by: Arnold | last post by:
Hi there, I have a form to organize bottles in mind, but am unsure if it will work. Here's some background info: Mainform = frmProduct, which contains fields for pricing, status, etc. of...
1
by: sixsoccer | last post by:
I have built a database with a <Mainform> and a <Subform>. My problem is twofold. 1. My subform is set as a continuos form with AllowAddiotions set to NO (ie. a list of Issues to the client on...
5
by: Bob | last post by:
Hi Everybody I have a form called frmListBox that is connected to a table tblListBox. This is opened from a form called "frmInvoiceOrder" which has a subform called "zfrmInvoiceOrder" and...
15
by: Susan Bricker | last post by:
Greetings. I have a Mainform with a subform. The Mainform has single record format and subform has continuous form format. When the Mainform opens, I force allowadditions and allowedits to FALSE...
13
by: ricky.agrawal | last post by:
I'm really not sure how to go about this in Access. What I've created is a table for each location. Those tables are identical in format but different in information. The tables are named after...
1
by: planetthoughtful | last post by:
Hi All, I have a mainform with a subform in which I show some task summary data. On the mainform I have a number of unbound controls that reflect values relevant to each task in the subform....
7
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...
1
by: Simon | last post by:
Dear reader, How can I find a record in a sub form, the sub form type is DataSheet and the record collection in the subform are to many to show them all in the subform window.
2
by: angi35 | last post by:
I hope this is an easy question for someone out there. In Access 2000…I have a MainForm with a tab control (MAIN TABS) with 7 tabs. Within each tab is a SubForm. Within each SubForm is a tab...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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,...

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.