Open Form just Add or just Edit

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!
 
E

Edward Lollar

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!
 
E

Edward Lollar

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!
 
D

Dirk Goldgar

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 -----
 
T

tina

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
 

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