![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a subform with the following code that i want to lock the fields in the current form if a field (text182) is -1 and keep it unlocked if it is 0. This works fine until i close out of the form and try to come back in. I get a run-time error '2427': You entered an expression that has no value. Private Sub Form_Current() If Me.Text182 = -1 Then Me.Resource.Locked = True Me.BOE.Locked = True Me.BOEAttachment.Locked = True Else Me.Resource.Locked = False Me.BOE.Locked = False Me.BOEAttachment.Locked = False End If End Sub Why do i get this error when entering the form? I am guessing it has to do with no data being populated yet in the subform. Any help would be great. thanks, Keith |
#3
| |||
| |||
|
|
kol... (AT) gmail (DOT) com wrote: I have a subform with the following code that i want to lock the fields in the current form if a field (text182) is -1 and keep it unlocked if it is 0. This works fine until i close out of the form and try to come back in. *I get a run-time error '2427': You *entered an expression that has no value. Private Sub Form_Current() If Me.Text182 = -1 Then Me.Resource.Locked = True Me.BOE.Locked = True Me.BOEAttachment.Locked = True Else Me.Resource.Locked = False Me.BOE.Locked = False Me.BOEAttachment.Locked = False End If End Sub Why do i get this error when entering the form? *I am guessing it has to do with no data being populated yet in the subform. *Any help would be great. thanks, Keith Perhaps check the status of it being a new record. *I don't believe the form_current event fires until you create a new record or have an existing record to work with and who knows what text182 is referencing. * Perhaps set a default value of 0 to Text182. If Not Me.newRecord or (me.NewRecord And Me.Text182 = -1) then * * * * ...your code endif- Hide quoted text - - Show quoted text - |
#4
| |||
| |||
|
|
On Jan 21, 11:28 am, Salad <o... (AT) vinegar (DOT) com> wrote: kol... (AT) gmail (DOT) com wrote: I have a subform with the following code that i want to lock the fields in the current form if a field (text182) is -1 and keep it unlocked if it is 0. This works fine until i close out of the form and try to come back in. I get a run-time error '2427': You entered an expression that has no value. Private Sub Form_Current() If Me.Text182 = -1 Then Me.Resource.Locked = True Me.BOE.Locked = True Me.BOEAttachment.Locked = True Else Me.Resource.Locked = False Me.BOE.Locked = False Me.BOEAttachment.Locked = False End If End Sub Why do i get this error when entering the form? I am guessing it has to do with no data being populated yet in the subform. Any help would be great. thanks, Keith Perhaps check the status of it being a new record. I don't believe the form_current event fires until you create a new record or have an existing record to work with and who knows what text182 is referencing. Perhaps set a default value of 0 to Text182. If Not Me.newRecord or (me.NewRecord And Me.Text182 = -1) then ...your code endif- Hide quoted text - - Show quoted text - Sorry, i should have been more detailed Text182 refers to a yes/no field on another subform. |
#5
| |||
| |||
|
|
kol... (AT) gmail (DOT) com wrote: On Jan 21, 11:28 am, Salad <o... (AT) vinegar (DOT) com> wrote: kol... (AT) gmail (DOT) com wrote: I have a subform with the following code that i want to lock the fields in the current form if a field (text182) is -1 and keep it unlocked if it is 0. This works fine until i close out of the form and try to come back in. *I get a run-time error '2427': You *entered an expression that has no value. Private Sub Form_Current() If Me.Text182 = -1 Then Me.Resource.Locked = True Me.BOE.Locked = True Me.BOEAttachment.Locked = True Else Me.Resource.Locked = False Me.BOE.Locked = False Me.BOEAttachment.Locked = False End If End Sub Why do i get this error when entering the form? *I am guessing it has to do with no data being populated yet in the subform. *Any help would be great. thanks, Keith Perhaps check the status of it being a new record. *I don't believe the form_current event fires until you create a new record or have an existing record to work with and who knows what text182 is referencing. *Perhaps set a default value of 0 to Text182. If Not Me.newRecord or (me.NewRecord And Me.Text182 = -1) then * * * *...your code endif- Hide quoted text - - Show quoted text - Sorry, i should have been more detailed Text182 refers to a yes/no field on another subform. Maybe you need to provide more detail to the problem.- Hide quoted text - - Show quoted text - |
#6
| |||
| |||
|
|
kol... (AT) gmail (DOT) com wrote: On Jan 21, 11:28 am, Salad <o... (AT) vinegar (DOT) com> wrote: kol... (AT) gmail (DOT) com wrote: I have a subform with the following code that i want to lock the fields in the current form if a field (text182) is -1 and keep it unlocked if it is 0. This works fine until i close out of the form and try to come back in. I get a run-time error '2427': You entered an expression that has no value. Private Sub Form_Current() If Me.Text182 = -1 Then Me.Resource.Locked = True Me.BOE.Locked = True Me.BOEAttachment.Locked = True Else Me.Resource.Locked = False Me.BOE.Locked = False Me.BOEAttachment.Locked = False End If End Sub Why do i get this error when entering the form? I am guessing it has to do with no data being populated yet in the subform. Any help would be great. thanks, Keith Perhaps check the status of it being a new record. I don't believe the form_current event fires until you create a new record or have an existing record to work with and who knows what text182 is referencing. Perhaps set a default value of 0 to Text182. If Not Me.newRecord or (me.NewRecord And Me.Text182 = -1) then ...your code endif- Hide quoted text - - Show quoted text - Sorry, i should have been more detailed Text182 refers to a yes/no field on another subform. Maybe you need to provide more detail to the problem.- Hide quoted text - - Show quoted text - |
#7
| |||
| |||
|
|
kol... (AT) gmail (DOT) com> wrote in message news:9665a228-3e92-486f-a60b-a2b0278a4f2f (AT) g38g2000yqd (DOT) googlegroups.com... On Jan 21, 11:55 am, Salad <o... (AT) vinegar (DOT) com> wrote: kol... (AT) gmail (DOT) com wrote: On Jan 21, 11:28 am, Salad <o... (AT) vinegar (DOT) com> wrote: kol... (AT) gmail (DOT) com wrote: I have a subform with the following code that i want to lock the fields in the current form if a field (text182) is -1 and keep it unlocked if it is 0. This works fine until i close out of the form and try to come back in. I get a run-time error '2427': You entered an expression that has no value. Private Sub Form_Current() If Me.Text182 = -1 Then Me.Resource.Locked = True Me.BOE.Locked = True Me.BOEAttachment.Locked = True Else Me.Resource.Locked = False Me.BOE.Locked = False Me.BOEAttachment.Locked = False End If End Sub Why do i get this error when entering the form? I am guessing it has to do with no data being populated yet in the subform. Any help would be great. thanks, Keith Perhaps check the status of it being a new record. I don't believe the form_current event fires until you create a new record or have an existing record to work with and who knows what text182 is referencing. Perhaps set a default value of 0 to Text182. If Not Me.newRecord or (me.NewRecord And Me.Text182 = -1) then ...your code endif- Hide quoted text - - Show quoted text - Sorry, i should have been more detailed Text182 refers to a yes/no field on another subform. Maybe you need to provide more detail to the problem.- Hide quoted text- - Show quoted text - Details: I have 2 subforms on a main form. *One subform has a list of all WBSId and the other is the estimated work for each of these wbsid's. *Some of these WBSids i don't want to allow the user to enter estimates. *In the WBS subform i have a checkbox for whether the user can input estimates or not. *If the checkbox is true then i want to lock the other subform from allowing changes (hiding the subform would be ok too). Does that help? thanks Is this code in the Current event of the main form, or the Current event of the Form embedded in a subform other than the one in which Text182 resides? In neither of those cases is that the appropriate reference. Tell us the names of the Subform controls, and the one in whose Form Text182 resides AND tell us where the code you include resides and someone can, at least, give you the appropriate way to reference that Field. *Larry Linson *Microsoft Office Access MVP- Hide quoted text - - Show quoted text - |
#8
| |||
| |||
|
|
On Jan 21, 6:44 pm, "Larry Linson" <boun... (AT) localhost (DOT) not> wrote: kol... (AT) gmail (DOT) com> wrote in message news:9665a228-3e92-486f-a60b-a2b0278a4f2f (AT) g38g2000yqd (DOT) googlegroups.com... On Jan 21, 11:55 am, Salad <o... (AT) vinegar (DOT) com> wrote: kol... (AT) gmail (DOT) com wrote: On Jan 21, 11:28 am, Salad <o... (AT) vinegar (DOT) com> wrote: kol... (AT) gmail (DOT) com wrote: I have a subform with the following code that i want to lock the fields in the current form if a field (text182) is -1 and keep it unlocked if it is 0. This works fine until i close out of the form and try to come back in. I get a run-time error '2427': You entered an expression that has no value. Private Sub Form_Current() If Me.Text182 = -1 Then Me.Resource.Locked = True Me.BOE.Locked = True Me.BOEAttachment.Locked = True Else Me.Resource.Locked = False Me.BOE.Locked = False Me.BOEAttachment.Locked = False End If End Sub Why do i get this error when entering the form? I am guessing it has to do with no data being populated yet in the subform. Any help would be great. thanks, Keith Perhaps check the status of it being a new record. I don't believe the form_current event fires until you create a new record or have an existing record to work with and who knows what text182 is referencing. Perhaps set a default value of 0 to Text182. If Not Me.newRecord or (me.NewRecord And Me.Text182 = -1) then ...your code endif- Hide quoted text - - Show quoted text - Sorry, i should have been more detailed Text182 refers to a yes/no field on another subform. Maybe you need to provide more detail to the problem.- Hide quoted text - - Show quoted text - Details: I have 2 subforms on a main form. One subform has a list of all WBSId and the other is the estimated work for each of these wbsid's. Some of these WBSids i don't want to allow the user to enter estimates. In the WBS subform i have a checkbox for whether the user can input estimates or not. If the checkbox is true then i want to lock the other subform from allowing changes (hiding the subform would be ok too). Does that help? thanks Is this code in the Current event of the main form, or the Current event of the Form embedded in a subform other than the one in which Text182 resides? In neither of those cases is that the appropriate reference. Tell us the names of the Subform controls, and the one in whose Form Text182 resides AND tell us where the code you include resides and someone can, at least, give you the appropriate way to reference that Field. Larry Linson Microsoft Office Access MVP- Hide quoted text - - Show quoted text - Thanks Larry! The code is in the current event of the subform (estimates subform) which has text182 in it. The text182 is a field that references another subform called "wbs_subform" =[Forms]![EstimatesForm]![WBS_subform].[Form]![Rollup] On the "wbs_subform" there is a field called "rollup" that is a yes/no field. The main form is called EstimatesForm. I hope that helps |
#9
| |||
| |||
|
|
kol... (AT) gmail (DOT) com wrote: On Jan 21, 6:44 pm, "Larry Linson" <boun... (AT) localhost (DOT) not> wrote: kol... (AT) gmail (DOT) com> wrote in message news:9665a228-3e92-486f-a60b-a2b0278a4f2f (AT) g38g2000yqd (DOT) googlegroups.com.... On Jan 21, 11:55 am, Salad <o... (AT) vinegar (DOT) com> wrote: kol... (AT) gmail (DOT) com wrote: On Jan 21, 11:28 am, Salad <o... (AT) vinegar (DOT) com> wrote: kol... (AT) gmail (DOT) com wrote: I have a subform with the following code that i want to lock the fields in the current form if a field (text182) is -1 and keep it unlocked if it is 0. This works fine until i close out of the form and try to come back in. I get a run-time error '2427': You entered an expression that has no value. Private Sub Form_Current() If Me.Text182 = -1 Then Me.Resource.Locked = True Me.BOE.Locked = True Me.BOEAttachment.Locked = True Else Me.Resource.Locked = False Me.BOE.Locked = False Me.BOEAttachment.Locked = False End If End Sub Why do i get this error when entering the form? I am guessing it has to do with no data being populated yet in the subform. Any help would be great. thanks, Keith Perhaps check the status of it being a new record. I don't believe the form_current event fires until you create a new record or have an existing record to work with and who knows what text182 is referencing. Perhaps set a default value of 0 to Text182. If Not Me.newRecord or (me.NewRecord And Me.Text182 = -1) then ...your code endif- Hide quoted text - - Show quoted text - Sorry, i should have been more detailed Text182 refers to a yes/no field on another subform. Maybe you need to provide more detail to the problem.- Hide quoted text - - Show quoted text - Details: I have 2 subforms on a main form. *One subform has a list of all WBSId and the other is the estimated work for each of these wbsid's. *Some of these WBSids i don't want to allow the user to enter estimates. *In the WBS subform i have a checkbox for whether the user can input estimates or not. *If the checkbox is true then i want to lock the other subform from allowing changes (hiding the subform would be ok too). Does that help? thanks Is this code in the Current event of the main form, or the Current event of the Form embedded in a subform other than the one in which Text182 resides? In neither of those cases is that the appropriate reference. Tell us the names of the Subform controls, and the one in whose Form Text182 resides AND tell us where the code you include resides and someone can,at least, give you the appropriate way to reference that Field. Larry Linson Microsoft Office Access MVP- Hide quoted text - - Show quoted text - Thanks Larry! The code is in the current event of the subform (estimates subform) which has text182 in it. The text182 is a field that references another subform called "wbs_subform" =[Forms]![EstimatesForm]![WBS_subform].[Form]![Rollup] On the "wbs_subform" there is a field called "rollup" that is a yes/no field. *The main form is called EstimatesForm. I hope that helps It might help if you mentioned something like * * * * EstimatesForm * * * * * * * * wbs_subform * * * * * * * * * * * * TheSubformWIthProb Can you enter records in the problem subform and not in wbs_subform? *If so, you could do something like If Forms!EstimatesForm!wbs_subform.Form.Recordsetclon e.Recordcount > 0 _ * * * * then * * * * ....your code endif as I assume there'd either be or not records in the wbs_subform.- Hide quoted text - - Show quoted text - |
![]() |
| Thread Tools | |
| Display Modes | |
| |