473,383 Members | 1,891 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,383 software developers and data experts.

Problem creating new records in a subform

Rabbit
12,516 Expert Mod 8TB
I have a tbl_Demo that is linked one to many to tbl_Services on DemoID.
I have a form for tbl_Demo with a continuous subform for tbl_Services.
Referential Integrity is turned on.

Before ever going into frm_Demo, there is an intermediary form with a button that first checks for overlaps and such. The button then opens frm_Demo and populates a couple of fields. It also needs to create 16 records to start out with in the subform.

I can't use DoCmd.GotoRecord , , acNewRec. Something about how I can't use that on a form in Design View.

I can't use DoCmd.GotoRecord , "frm_Sub_Services". Says that it's not open.

I tried to do it through the subform's recordset clone but it says there needs to be a related record in tbl_Demo. Then again, I didn't set the value of tbl_Services.DemoID to match tbl_Demo.DemoID. But the whole point of referential integrity was to avoid this.

Is there another method?
Mar 14 '07 #1
2 1920
ADezii
8,834 Expert 8TB
I have a tbl_Demo that is linked one to many to tbl_Services on DemoID.
I have a form for tbl_Demo with a continuous subform for tbl_Services.
Referential Integrity is turned on.

Before ever going into frm_Demo, there is an intermediary form with a button that first checks for overlaps and such. The button then opens frm_Demo and populates a couple of fields. It also needs to create 16 records to start out with in the subform.

I can't use DoCmd.GotoRecord , , acNewRec. Something about how I can't use that on a form in Design View.

I can't use DoCmd.GotoRecord , "frm_Sub_Services". Says that it's not open.

I tried to do it through the subform's recordset clone but it says there needs to be a related record in tbl_Demo. Then again, I didn't set the value of tbl_Services.DemoID to match tbl_Demo.DemoID. But the whole point of referential integrity was to avoid this.

Is there another method?
Rabbit:
I'm not exactly sure if this is what you were requesting, but I'll give it a shot anyway. The following code will:
__1. Save the Parent Record in frmDemo.
__2. Set Focus to the Sub-Form Control.
__3. Add a New Record to the Sub Form frm_Sub_Services. You need never explicitly mention this Sub Form by Name, only its Container.
Expand|Select|Wrap|Line Numbers
  1. __1. SendKeys "+{ENTER}", True
  2. __2. Me![<sub form control name>].SetFocus
  3. __3. DoCmd.GoToRecord , , acNewRec
NOTE: I'm probably totally off track but please let me know if this is what you were trying to accomplish.
Mar 15 '07 #2
Rabbit
12,516 Expert Mod 8TB
Rabbit:
I'm not exactly sure if this is what you were requesting, but I'll give it a shot anyway. The following code will:
__1. Save the Parent Record in frmDemo.
__2. Set Focus to the Sub-Form Control.
__3. Add a New Record to the Sub Form frm_Sub_Services. You need never explicitly mention this Sub Form by Name, only its Container.
Expand|Select|Wrap|Line Numbers
  1. __1. SendKeys "+{ENTER}", True
  2. __2. Me![<sub form control name>].SetFocus
  3. __3. DoCmd.GoToRecord , , acNewRec
NOTE: I'm probably totally off track but please let me know if this is what you were trying to accomplish.
Not quite what I was looking for. The code is actually running from another form so I can't use Me. I tried to set the focus to it using Forms!frm_Demo!frm_Sub_Services.SetFocus but it says I can't set focus to that control.
Mar 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bruno Luis | last post by:
Hello I'm using A97 and i'm having some trouble with creating a recordset with data from two different databases. I connect to a remote database and make this data the default source for my...
2
by: CSDunn | last post by:
Hello, In an Access 2003 ADP Subform, I am trying to set the BackGround color of three textbox fields (LSScore, RScore, WScore) in the current record of the subform to zero (black) if the value of...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
5
by: DS | last post by:
I have a form with 2 Subforms...The first subform is linked to the main form. The second Subform is liked to the first subform. Whenever I add a record to the first subform that works fine. When...
5
by: keith | last post by:
This may seem simple, but I'm having a bit of trouble figuring out exactly how to do it. I'm accessing a database through an ODBC link, and I have a query that returns only jobs completed that day...
1
by: Terry | last post by:
Hello, Has anyone experienced the following problem following an Upsize from Access 97 to SQL 2000 using the MS Upsize Wizard? Or can anyone see what the problem might be. Before Upsize...
13
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a...
7
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.