A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Disabling New Records on Forms in VB



 
 
Thread Tools Display Modes
  #1  
Old March 14th, 2007, 01:46 PM posted to microsoft.public.access.forms
John Ortt
external usenet poster
 
Posts: 39
Default Disabling New Records on Forms in VB

Hi Everyone,

I have designed a form which successfully supresses the ability to create
new records by setting the AllowAdditions property to "No".

The problem is that when I open the form using the code below the form once
again allows additions and I can't figure out how to prevent this.

I tagged the "Me.AllowAdditions = False" into the openargs section but to no
avail.

If anyone can spot the problem in my code I would be very grateful.

Thanks,

John

******* Start Code *******

Private Sub cmdView_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmForm"
stLinkCriteria = "[strIndex]=" & Me.ctlIndex.Value
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit, ,
Me.AllowAdditions = False

End Sub

******** End Code ********


  #2  
Old March 14th, 2007, 01:57 PM posted to microsoft.public.access.forms
SusanV
external usenet poster
 
Posts: 399
Default Disabling New Records on Forms in VB

Hi John,

Put the Me.
AllowAdditions = False line in the On Open argument of the form, rather than
in the sub of the code calling the form.
--
hth,
SusanV


"John Ortt" wrote in message
...
Hi Everyone,

I have designed a form which successfully supresses the ability to create
new records by setting the AllowAdditions property to "No".

The problem is that when I open the form using the code below the form
once again allows additions and I can't figure out how to prevent this.

I tagged the "Me.AllowAdditions = False" into the openargs section but to
no avail.

If anyone can spot the problem in my code I would be very grateful.

Thanks,

John

******* Start Code *******

Private Sub cmdView_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmForm"
stLinkCriteria = "[strIndex]=" & Me.ctlIndex.Value
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit, ,
Me.AllowAdditions = False

End Sub

******** End Code ********



  #3  
Old March 14th, 2007, 02:06 PM posted to microsoft.public.access.forms
Al Campagna
external usenet poster
 
Posts: 647
Default Disabling New Records on Forms in VB

John,
If, in design mode, you set the AllowAdditions to NO, then there's no need to involve
AllowAdditions in the form opening code. The form will open with that property already
set, and will remain set until you change that property in the form code, or change the
design setting.
Also, the OpenArgs argument in the OpenForm method does not handle "code". It used to
pass a variable to the form.

And, it appears that the use of acFormEdit is overriding the form's AllowAdditions
setting.
Just try....
DoCmd.OpenForm stDocName,,, stLinkCriteria
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."


"John Ortt" wrote in message
...
Hi Everyone,

I have designed a form which successfully supresses the ability to create new records by
setting the AllowAdditions property to "No".

The problem is that when I open the form using the code below the form once again allows
additions and I can't figure out how to prevent this.

I tagged the "Me.AllowAdditions = False" into the openargs section but to no avail.

If anyone can spot the problem in my code I would be very grateful.

Thanks,

John

******* Start Code *******

Private Sub cmdView_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmForm"
stLinkCriteria = "[strIndex]=" & Me.ctlIndex.Value
DoCmd.OpenForm stDocName, ,, stLinkCriteria, acFormEdit, , Me.AllowAdditions = False

End Sub

******** End Code ********



  #4  
Old March 14th, 2007, 03:15 PM posted to microsoft.public.access.forms
John Ortt
external usenet poster
 
Posts: 39
Default Disabling New Records on Forms in VB

Cheers Al,

You were right, simply removing the "acFormEdit" from the string is allowing
it to work as intended.

Thank you very much.

John


"Al Campagna" alcampagna@msnewsgroups wrote in message
...
John,
If, in design mode, you set the AllowAdditions to NO, then there's no
need to involve AllowAdditions in the form opening code. The form will
open with that property already set, and will remain set until you change
that property in the form code, or change the design setting.
Also, the OpenArgs argument in the OpenForm method does not handle
"code". It used to pass a variable to the form.

And, it appears that the use of acFormEdit is overriding the form's
AllowAdditions setting.
Just try....
DoCmd.OpenForm stDocName,,, stLinkCriteria
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."


"John Ortt" wrote in message
...
Hi Everyone,

I have designed a form which successfully supresses the ability to create
new records by setting the AllowAdditions property to "No".

The problem is that when I open the form using the code below the form
once again allows additions and I can't figure out how to prevent this.

I tagged the "Me.AllowAdditions = False" into the openargs section but to
no avail.

If anyone can spot the problem in my code I would be very grateful.

Thanks,

John

******* Start Code *******

Private Sub cmdView_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmForm"
stLinkCriteria = "[strIndex]=" & Me.ctlIndex.Value
DoCmd.OpenForm stDocName, ,, stLinkCriteria, acFormEdit, ,
Me.AllowAdditions = False

End Sub

******** End Code ********





  #5  
Old March 14th, 2007, 03:18 PM posted to microsoft.public.access.forms
John Ortt
external usenet poster
 
Posts: 39
Default Disabling New Records on Forms in VB

Thanks for the reply Susan

I ended up trying Al's suggestion of removing the "acFormEdit " from the
string used to open the form and this worked perfectly.

My next point of call would have been your suggestion of adding the code to
the onopen event but it wasn't needed.

Thanks for taking the time to help.

All the best,

John



"SusanV" wrote in message
...
Hi John,

Put the Me.
AllowAdditions = False line in the On Open argument of the form, rather
than in the sub of the code calling the form.
--
hth,
SusanV


"John Ortt" wrote in message
...
Hi Everyone,

I have designed a form which successfully supresses the ability to create
new records by setting the AllowAdditions property to "No".

The problem is that when I open the form using the code below the form
once again allows additions and I can't figure out how to prevent this.

I tagged the "Me.AllowAdditions = False" into the openargs section but to
no avail.

If anyone can spot the problem in my code I would be very grateful.

Thanks,

John

******* Start Code *******

Private Sub cmdView_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmForm"
stLinkCriteria = "[strIndex]=" & Me.ctlIndex.Value
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit, ,
Me.AllowAdditions = False

End Sub

******** End Code ********





  #6  
Old March 14th, 2007, 03:26 PM posted to microsoft.public.access.forms
SusanV
external usenet poster
 
Posts: 399
Default Disabling New Records on Forms in VB

No problem, glad you got the answer you needed

;-D

"John Ortt" wrote in message
...
Thanks for the reply Susan

I ended up trying Al's suggestion of removing the "acFormEdit " from the
string used to open the form and this worked perfectly.

My next point of call would have been your suggestion of adding the code
to the onopen event but it wasn't needed.

Thanks for taking the time to help.

All the best,

John



"SusanV" wrote in message
...
Hi John,

Put the Me.
AllowAdditions = False line in the On Open argument of the form, rather
than in the sub of the code calling the form.
--
hth,
SusanV


"John Ortt" wrote in message
...
Hi Everyone,

I have designed a form which successfully supresses the ability to
create new records by setting the AllowAdditions property to "No".

The problem is that when I open the form using the code below the form
once again allows additions and I can't figure out how to prevent this.

I tagged the "Me.AllowAdditions = False" into the openargs section but
to no avail.

If anyone can spot the problem in my code I would be very grateful.

Thanks,

John

******* Start Code *******

Private Sub cmdView_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmForm"
stLinkCriteria = "[strIndex]=" & Me.ctlIndex.Value
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit, ,
Me.AllowAdditions = False

End Sub

******** End Code ********







 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:10 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.