Disabling New Record Button (1 Viewer)

Haynesey

Registered User.
Local time
Today, 12:41
Joined
Dec 19, 2001
Messages
190
Hi,

On licking on a button to add a new record, i use the following code so that only a blank record appears,hiding all existing data. However, once a new record has been created, there is nothing to stop the user clicking on the New Record button. Can this be disabled as only one recird should be able to be entered at a time?

DoCmd.OpenForm "frmHD", acNormal, , , acFormAdd

Cheers in advance

Lee
 

Rakier

Registered User.
Local time
Today, 12:41
Joined
Mar 21, 2002
Messages
75
Put this after your code:

DoCmd.OpenForm "frmHD", acNormal, , , acFormAdd

Forms!frmHd.cmdNewRecord.enabled = False

Make sure to replace cmdNewRecord with the name of your command button that allows a user to create a new record.

This will disable that button.

HTH
 

Haynesey

Registered User.
Local time
Today, 12:41
Joined
Dec 19, 2001
Messages
190
Thanks

Hi,

That works but I also need to be able to disable the New Record button on the toolbar. Is there a line of code just to do that?

Thanks again
Lee
 

Tim K.

Registered User.
Local time
Today, 12:41
Joined
Aug 1, 2002
Messages
242
You can use AllowAddtions property like this.

Code:
Private Sub Toggle14_Click()
    Me.AllowAdditions = Not (Me.AllowAdditions)
End Sub

I use a toggle button to enable or disable the Add New button.
 

Rakier

Registered User.
Local time
Today, 12:41
Joined
Mar 21, 2002
Messages
75
Or alternatively, you could also change the code from before to:

with forms!frmHd
.cmdNewRecord.enabled = False
.allowadditions = False
End with

That should do the trick. I'm not sure how to disable the toolbar button, but I think that the .alloweditions thing should work even if the toolbar button is clicked.
 

Users who are viewing this thread

Top Bottom