Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add New Record does not work on form

Status
Not open for further replies.

lenderb

MIS
Apr 4, 2005
3
US
I have a form opening in Read-Only mode to prevent altering the data. Then the Add Record button does not work. How can I get the Add Record button to work on a form that is in Read-Only mode. Or is there another way to prevent altering data by accident? Each field is a combo box for ease in finding records.
 
Code:
Private Sub Form_Open(Cancel As Integer)
    Me.AllowAdditions = False
    Me.AllowEdits = False
    Me.AllowDeletions = False
End Sub
Code:
Public Sub CmdAddNew_Click()
    Me.AllowAdditions = True
    DoCmd.GoToRecord , , acNewRec
End Sub
Code:
Private Sub cmdEditRecord_Click()
    Me.AllowEdits = True
End Sub
Code:
Private Sub cmdDeleteRecord_Click()
    Me.AllowDeletions = True
End Sub
Code:
Private Sub cmdSave_Click()
    Me.AllowAdditions = False
    Me.AllowDeletions = False
    Me.AllowEdits = False
End Sub
And you need to disable / Enable the command buttons for each instance.

________________________________________
Zameer Abdulla
Visit Me
Hold your child's hand every chance you get.
A time will come when he or she won't let you.
 
Code:
[COLOR=blue]Private[/color] Sub CmdAddNew_Click()
    Me.AllowAdditions = True
    DoCmd.GoToRecord , , acNewRec
End Sub
There is a mistake. It should be read as Private not Public

________________________________________
Zameer Abdulla
Visit Me
Hold your child's hand every chance you get.
A time will come when he or she won't let you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top