prevent subform from moving to next record (1 Viewer)

snorf3

Registered User.
Local time
Today, 04:47
Joined
May 25, 2001
Messages
45
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!
 
R

Rich

Guest
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

Registered User.
Local time
Today, 04:47
Joined
Aug 12, 2001
Messages
531
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

Registered User.
Local time
Today, 04:47
Joined
Aug 12, 2001
Messages
531
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.
 

jwindon

Registered User.
Local time
Today, 04:47
Joined
Aug 12, 2001
Messages
531
Rich or snorf:

Where is the Cycle property? I don't see anything by that name.
 

R. Hicks

AWF VIP
Local time
Yesterday, 22:47
Joined
Dec 23, 1999
Messages
619
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
 

Users who are viewing this thread

Top Bottom