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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|