How to detect navigation

J

jim

Hello, I have a main form and a subform. The subform has a command button
that calls a popup form that updates contacts related to subform. All is
working great except that when user navigates to a new record either on the
main form or the subform, the last entry in the popup form is saved to new
record relationship. How can I detect when user moves to a new record
-either in subform or main form? I tried to close the subform on the main's
current but that doesn't work. TIA
 
S

Stefan Hoffmann

hi Jim,

How can I detect when user moves to a new record
-either in subform or main form? I tried to close the subform on the main's
current but that doesn't work. TIA
Use the Form's NewRecord property, e.g.

If Me.NewRecord Or subformControl.Form.NewRecord Then
'...
End If


mfG
--> stefan <--
 
S

Stefan Hoffmann

hi Jim,

How can I detect when user moves to a new record
-either in subform or main form? I tried to close the subform on the main's
current but that doesn't work. TIA
Use the Form's NewRecord property, e.g.

If Me.NewRecord Or subformControl.Form.NewRecord Then
'...
End If


mfG
--> stefan <--
 
D

Dorian

Try:
If Me.NewRecord then ...

from Access Help:

NewRecord Property
See AlsoApplies ToExampleSpecificsYou can use the NewRecord property to
determine whether the current record is a new record. Read-only Integer.

expression.NewRecord
expression Required. An expression that returns one of the objects in the
Applies To list.

Remarks
The NewRecord property uses the following settings.

Setting Description
True The current record is new.
False The current record isn't new.


Note The NewRecord property is read-only in Form view and Datasheet view.
It isn't available in Design view. This property is available only by using a
macro or Visual Basic.

When a user has moved to a new record, the NewRecord property setting will
be True whether the user has started to edit the record or not.

Example
The following example shows how to use the NewRecord property to determine
if the current record is a new record. The NewRecordMark procedure sets the
current record to the variable intnewrec. If the record is new, a message is
displayed notifying the user of this. You could run this procedure when the
Current event for a form occurs.

Sub NewRecordMark(frm As Form)
Dim intnewrec As Integer

intnewrec = frm.NewRecord
If intnewrec = True Then
MsgBox "You're in a new record." _
& "@Do you want to add new data?" _
& "@If not, move to an existing record."
End If
End Sub


-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
J

jim

Thanks Steven for response. What event can I use to put code in -current
doesn't work? I need to do it before current.
TIA
 
S

Stefan Hoffmann

hi Jim,

Thanks Steven for response. What event can I use to put code in -current
doesn't work? I need to do it before current.
I'm not sure, as you original description is not that clear - I'm not
sure that I understood your intended kind of navigation.


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top