Results 1 to 2 of 2
2006-04-05, 15:23 #1
- Join Date
- Jan 2001
- austin, Texas, USA
- Thanked 0 Times in 0 Posts
Creating new record in subform in code (Access 2K, Win 2KPro, SQL Server 2
I have a form (M) with a subform (A), and on this subform is another subform ([img]/forums/images/smilies/cool.gif[/img]. On the (A) subform, I have a button that adds a new record to the subform, and I want to also have the vb code go to the ([img]/forums/images/smilies/cool.gif[/img] subform and have that move to a new record as well. Since the button is on subform (A), I can use DoCmd.GoToRecord , , acNewRec to create a new record there, but I'm having trouble getting this to work on the ([img]/forums/images/smilies/cool.gif[/img] subform. I can SetFocus easily enough but from there... weirdness.
With the subform ([img]/forums/images/smilies/cool.gif[/img] selected, I put this in: DoCmd.GoToRecord , acActiveDataObject, acNewRec and get this response:
The object '-1' isn't open [OK]
previous attempts to use bang notation to find the subform subform for this requirement have met with no success. I can reference a control on subform (A) in the default on the properties sheet but it doesn't seem to work in code.
2006-04-05, 15:35 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 Posts
Re: Creating new record in subform in code (Access 2K, Win 2KPro, SQL Serv
If B is linked to A through its Link Master Fields and Link Child Fields properties, it should automatically display a new record if you move to a new record in A.
If B is not linked to A, you could use this:
where BName should be the name of B as a control on A. This is not necessarily the same as its name in the database window.