snorf3
08-16-2001, 12:57 PM
I want to stop a subform from moving to the next record or a new record after you hit enter or tab from the last field of that form.
How can make it go to a new record of the master form instead?
The master and sub forms are based on 2 tables with a one-to-one relationship so I don't want the subform to go to a new record while the master form stays on the same record.
Is there something I can do so that when you reach the end of the subform, it forces a new master form accompanied by new subform?
Hope this makes sense!
Set the cycle property of the subform to current record. In the after update event of your last textbox of the sub put Forms!MainFormName!TextName.SetFocus
jwindon
08-16-2001, 03:49 PM
Not sure if this is what you are looking for. I'm guessing that you want the subform data to be in edit mode.
Set your subform property to Allow Additions: No. AllowEdits: Yes.
On the last control of your subform, set the property of OnLostFocus to the following Code:
(between where it says Sub...and End Sub
DoCmd.GoToRecord , , acNewRec
FirstControl.SetFocus
Where I wrote "First Control" you would enter the name of the control on your main form you want to begin with.
Hope this helps.
jwindon
08-16-2001, 04:04 PM
OK. That didn't actually work. I wrote the Code wrong. I'm still new to THAT part. Anyway, I was able to accomplish what you wanted using a macro. I don't have the files installed to actually SEE the Code generated by the macro, but it is set like this:
Macro7
GoRecord with Arguments of Forms, MainForm'sName,New, Offset is blank.
Then
GoToControl
Argument is FirstControl'sName
Put the Macro7 where I said to put the Code.
Rich: Where is the Cycle property? I don't see anything by that name.
snorf3
08-17-2001, 08:09 AM
Rich,
Thanks. It works great.
jwindon
08-17-2001, 03:34 PM
Rich or snorf:
Where is the Cycle property? I don't see anything by that name.
R. Hicks
08-17-2001, 04:26 PM
To get to the Cycle property for the subform, you will need to open the subform in design view. Then you will find this property in the property list for the form.
HTH
RDH