dbTalk Databases Forums  

Error in Code When opening Form

comp.databases.ms-access comp.databases.ms-access


Discuss Error in Code When opening Form in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
kolsby@gmail.com
 
Posts: n/a

Default Error in Code When opening Form - 01-21-2009 , 12:51 PM






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

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Error in Code When opening Form - 01-21-2009 , 01:28 PM






kolsby (AT) gmail (DOT) com wrote:
Quote:
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


Reply With Quote
  #3  
Old   
kolsby@gmail.com
 
Posts: n/a

Default Re: Error in Code When opening Form - 01-21-2009 , 01:30 PM



On Jan 21, 11:28*am, Salad <o... (AT) vinegar (DOT) com> wrote:
Quote:
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.


Reply With Quote
  #4  
Old   
Salad
 
Posts: n/a

Default Re: Error in Code When opening Form - 01-21-2009 , 01:55 PM



kolsby (AT) gmail (DOT) com wrote:
Quote:
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.


Reply With Quote
  #5  
Old   
kolsby@gmail.com
 
Posts: n/a

Default Re: Error in Code When opening Form - 01-21-2009 , 03:02 PM



On Jan 21, 11:55*am, Salad <o... (AT) vinegar (DOT) com> wrote:
Quote:
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


Reply With Quote
  #6  
Old   
Larry Linson
 
Posts: n/a

Default Re: Error in Code When opening Form - 01-21-2009 , 08:44 PM



<kolsby (AT) gmail (DOT) com> wrote

On Jan 21, 11:55 am, Salad <o... (AT) vinegar (DOT) com> wrote:
Quote:
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




Reply With Quote
  #7  
Old   
kolsby@gmail.com
 
Posts: n/a

Default Re: Error in Code When opening Form - 01-22-2009 , 09:43 AM



On Jan 21, 6:44*pm, "Larry Linson" <boun... (AT) localhost (DOT) not> wrote:
Quote:
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


Reply With Quote
  #8  
Old   
Salad
 
Posts: n/a

Default Re: Error in Code When opening Form - 01-22-2009 , 01:19 PM



kolsby (AT) gmail (DOT) com wrote:

Quote:
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.



Reply With Quote
  #9  
Old   
kolsby@gmail.com
 
Posts: n/a

Default Re: Error in Code When opening Form - 01-22-2009 , 01:36 PM



On Jan 22, 11:19*am, Salad <o... (AT) vinegar (DOT) com> wrote:
Quote:
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 -
Thank you! Putting that code before my code worked!
i appreciate your help
KO


Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.