Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2007

Tip: Looking for answers? Try searching our database.

Disabling New Records on Forms in VB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Ortt - 14 Mar 2007 14:46 GMT
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 ********
SusanV - 14 Mar 2007 14:57 GMT
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.
Signature

hth,
SusanV

> Hi Everyone,
>
[quoted text clipped - 28 lines]
>
> ******** End Code ********
John Ortt - 14 Mar 2007 16:18 GMT
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

> Hi John,
>
[quoted text clipped - 33 lines]
>>
>> ******** End Code ********
SusanV - 14 Mar 2007 16:26 GMT
No problem, glad you got the answer you needed

;-D

> Thanks for the reply Susan
>
[quoted text clipped - 47 lines]
>>>
>>> ******** End Code ********
Al Campagna - 14 Mar 2007 15:06 GMT
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
Signature

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."

> Hi Everyone,
>
[quoted text clipped - 26 lines]
>
> ******** End Code ********
John Ortt - 14 Mar 2007 16:15 GMT
Cheers Al,

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

Thank you very much.

John

> John,
>   If, in design mode, you set the AllowAdditions to NO, then there's no
[quoted text clipped - 40 lines]
>>
>> ******** End Code ********
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.