A family of Microsoft relational database management systems designed for ease of use.
Thanks for the information and advice. I really appreciate this.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I tried the following codes for adding item not in list:
| Private SUPERVISOR_NotInList(NewData As String, Response As Integer) |
|---|
| If MsgBox("Person not in list, add to List?", vbYesNo, "Warning") = vbYes Then |
| DoCmd.OpenForm "FRM_COUNTTEAM", acNormal, , , acFormAdd, acDialog, NewData |
| Response = acDataErrAdded |
| End If |
| End Sub |
In the FRM_COUNTTEAM, I have the following codes in the form property On OPEN event:
| Private Sub Form_Open(Cancel As Integer) |
|---|
| If IsNull(Me.OpenArgs) Then |
| Else |
| cmdAddNew_Click |
| Name = Me.OpenArgs |
| End If |
| End Sub |
But the error comes out
| runtime error 2135 this property is read only and can't be set<br><br><br>Not sure what causing the error. Please advise. |
|---|
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Thanks for the information and advice. I really appreciate this.
Regardless of the inadvisable use of Name as a column name, your code is a little sparse, and takes no account of the possibility that a user might change their mind and undo the update of the FRM_COUNTTEAM form. For examples of the use of the NotInList event procedure in various contexts see NotInList.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
In this little demo file the NotInList event procedure of the CityID control in the contacts form, and the accompanying code in the cities form's Open event procedure, is the appropriate model for what you are doing.
However, a more fundamental issue here is that personal names are not distinct, and can legitimately be duplicated. I worked with two Maggie Taylors. You might consider this a remote possibility, but even a remote possibility is still a possibility, and a well designed database will take account of this. The opening form of my demo illustrates an alternative approach by means of a command button.
"Name" refers to the name of the form running the code (a good reason for not giving a field the name "Name"). Try enclosing Name in square brackets:
Me.[Name] = Me.OpenArgs
or
Me![Name] = Me.OpenArgs
I suspect this is a case of using a reserved word. A Form has a read-only Name property; Access assumes you are referring to it, and you're assuming you're referring to a field or control with the name Name.
If there is a field named Name in the form's recordsource, try changing the fieldname in the table to SupervisorName or some other non-reserved word. You may be able to get away without doing so by explicitly referencing the form control in brackets, so the program doesn't think you're referencing a property:
Me.[Name] = Me.OpenArgs
I tried the following codes for adding item not in list:
Private SUPERVISOR_NotInList(NewData As String, Response As Integer) If MsgBox("Person not in list, add to List?", vbYesNo, "Warning") = vbYes Then DoCmd.OpenForm "FRM_COUNTTEAM", acNormal, , , acFormAdd, acDialog, NewData Response = acDataErrAdded End If End Sub In the FRM_COUNTTEAM, I have the following codes in the form property On OPEN event:
Private Sub Form_Open(Cancel As Integer) If IsNull(Me.OpenArgs) Then Else cmdAddNew_Click Name = Me.OpenArgs End If End Sub But the error comes out
runtime error 2135 this property is read only and can't be set<br><br><br>Not sure what causing the error. Please advise. Further information, debug stop at :
Name = Me.OpenArgs