Move to new record from subForm using codes

FuzMic

DataBase Tinker
Local time
Today, 23:05
Joined
Sep 13, 2006
Messages
744
Hi friends

A quick one . User at sub form, i want to give him a dialog box when he leaves a sub form record that will move him to a new record in the sub form. At this point i would like to offer user an option to move to new record in the main form instead. Got it, i hope?

I was thinking about using RunCommand, not sure if it is best practice, if so what flag to use, THEN .. i think of my friends, so this question. :D
 
you do it in the Exit() Event of the subform.
click on the border of the subform in design view until you see the yellow/gold box around it (meaning it is selected). on its property->event, choose and add code to OnExit event:

Code:
Private Sub subFormName_Exit(Cancel As Integer)
    If MsgBox("Create New Record in " & [Form].Name & " form?", vbQuestion + vbYesNo) = vbYes Then
        DoCmd.GoToRecord acDataForm, [Form].Name, acNewRec
    End If
End Sub
 
Thank you Bro.

..BUT.. I have no chance to get to the Exit Event of the subform; it just move to a new Record in the SubFrm. You codes will come in handy if user move cursor to the main form, thus firing the Exit Event; until tht is done we are not given a chance to open new record in the MainFrm.

What i need to do is first fire the subForm Exit Event
 
Last edited:
I don't understand, boss.
 
Sorry
Again how to fire the exit event of the subform?
 
on desing view, click on the Border of the subform (not the upper square of the subform).
if you see a bright border around the subform, you are on the right path. if not, click anywhere in the main form and again try to click on the subform's border until it you see it with bright rectangle around it.

go to to iproperty->event, On Exit, choose Event Procedure, copy the code I gave you inside the sub.
 
Miss communication
I can put the codes in the on exit event, that is not my issue s
 

Users who are viewing this thread

Back
Top Bottom