Open Form just Add or just Edit

  • Thread starter Thread starter Chris B
  • Start date Start date
C

Chris B

I think this is simple but.... I have a master form to
display with two buttons under. The first button edits
just the curent record, the second adds a new record.
Both work, however when someone selects the edit they can
role the mouse into a new record (navigation is off) how
do prevent this with just one form but two ways to open.

HELP!
 
Chris,

Open the properties for the form. Go to Other\Cycle . . . change the value
to Current Record instead of All Records.

Hope this helps.

Edward
10:25:20 >>>
I think this is simple but.... I have a master form to
display with two buttons under. The first button edits
just the curent record, the second adds a new record.
Both work, however when someone selects the edit they can
role the mouse into a new record (navigation is off) how
do prevent this with just one form but two ways to open.

HELP!
 
Chris,

Open the properties for the form, go to Other\Cycle and change the value to
Current Record.

Hope this helps.

Edward
10:25:20 >>>
I think this is simple but.... I have a master form to
display with two buttons under. The first button edits
just the curent record, the second adds a new record.
Both work, however when someone selects the edit they can
role the mouse into a new record (navigation is off) how
do prevent this with just one form but two ways to open.

HELP!
 
Chris B said:
I think this is simple but.... I have a master form to
display with two buttons under. The first button edits
just the curent record, the second adds a new record.
Both work, however when someone selects the edit they can
role the mouse into a new record (navigation is off) how
do prevent this with just one form but two ways to open.

HELP!

The combination of these event procedures should handle it:

'----- start of code -----
Private Sub cmdAddRecord_Click()
' This is the button that adds a record.

Me.AllowAdditions = True
RunCommand acCmdRecordsGoToNew

End Sub


Private Sub cmdCancelAdd_Click()
' This is a button to cancel adding.

Me.Undo
Me.AllowAdditions = False

End Sub


Private Sub Form_AfterInsert()

Me.AllowAdditions = False

End Sub


Private Sub Form_Current()

If Not Me.NewRecord Then
Me.AllowAdditions = False
End If

End Sub
'----- end of code -----
 
try this:

set the form's OnCurrent event procedure as

Me.AllowAdditions = IsNull(Me!PrimaryKeyFieldName)

set the command button's click event (or double click, whatever) as

Me.AllowAdditions = True
DoCmd.RunCommand acCmdRecordsGoToNew

keep the Cycle set to Current Record.

hth
 
Back
Top