A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

"step"ing through code



 
 
Thread Tools Display Modes
  #1  
Old October 8th, 2004, 07:33 PM
jc
external usenet poster
 
Posts: n/a
Default "step"ing through code

I have a subform on a main form. The subform shows all
related parts to a drawing on the main form. I have a
control on the subform that sums all those parts on the
subform. I reference that control from the main form and
want a label to be visible if the quantity is 0 and not
visible if it is greater than 0. This is the code in
the "On Current" event for the main form.

Private Sub Form_Current()
If Me!sfrmXLList.Form!SumQTO 0 Then
Me.lblRFI.Visible = False
Else
Me.lblRFI.Visible = True
End If
End Sub

If I "step" through the code, the label changes visibility
as I expect. If I "run" the code, the label is always
visible.
Can someone tell me what is going on?
Thanks
- jc -
  #2  
Old October 8th, 2004, 09:40 PM
Ki Yi [MS]
external usenet poster
 
Posts: n/a
Default

Hello,

Your code looks fine. It possible that this problem is specific to that
particular form due to corruption.
Open the Orders form in the Northwind sample database and copy/paste the
following code:

If Me.[Orders Subform].Form![ExtendedPrice] 100 Then
Me![Freight label].Visible = False
Else
Me![Freight label].Visible = True
End If

If above code works then most likely there's some kind of corruption in
your forms. You can try recreating
the form (main or subform) from scratch or export them out into a new
database to see if it helps.

Regards,

Ki Yi
Microsoft Support

This posting is provided AS IS with no warranties, and confers no rights.

  #3  
Old October 12th, 2004, 06:53 PM
JC
external usenet poster
 
Posts: n/a
Default

Ki Yi,
Thank you for looking into this for me...

I think that what you are suggesting is different from what I am trying
to do. I want to SUM all the line items on the subform which is a continuous
form, not a datasheet form.

I have tried printing the results in the following code that is located in
the On Current on the Main form:

if Me!sfrmXLList.Form!SumQTO 0 then
MsgBox "if" & Str(Me!sfrmXLList.Form!SumQTO)
Me.lblRFI.Visible = False
else
MsgBox "if" & Str(Me!sfrmXLList.Form!SumQTO)
Me.lblRFI.visible = True
endif

and the MsgBox always evaluates to "if 0" and an OK button no matter what
the sum of QTO is. Even if the Sum is equal to zero, it is still evaluated
as being greater than zero and THEN when it prints it, it shows that it is
zero. When I step through the code the code "acts" like I would expect it to.
I can send you a zipped file (27k) if you would like to see what my problem
is.
Thanks again.
- jc -


"Ki Yi [MS]" wrote:

Hello,

Your code looks fine. It possible that this problem is specific to that
particular form due to corruption.
Open the Orders form in the Northwind sample database and copy/paste the
following code:

If Me.[Orders Subform].Form![ExtendedPrice] 100 Then
Me![Freight label].Visible = False
Else
Me![Freight label].Visible = True
End If

If above code works then most likely there's some kind of corruption in
your forms. You can try recreating
the form (main or subform) from scratch or export them out into a new
database to see if it helps.

Regards,

Ki Yi
Microsoft Support

This posting is provided AS IS with no warranties, and confers no rights.


  #4  
Old October 12th, 2004, 07:15 PM
JC
external usenet poster
 
Posts: n/a
Default

Ki Yi
Please accept my humble apology...It does work as advertised and it IS the
same as what I am trying to do. I will go back over it AGAIN and see what I
can do. Thanks for you time and please ignore my previous post. If you
don't mind, please check back and I will post on what I can get it to do.

- jc -

"Ki Yi [MS]" wrote:

Hello,

Your code looks fine. It possible that this problem is specific to that
particular form due to corruption.
Open the Orders form in the Northwind sample database and copy/paste the
following code:

If Me.[Orders Subform].Form![ExtendedPrice] 100 Then
Me![Freight label].Visible = False
Else
Me![Freight label].Visible = True
End If

If above code works then most likely there's some kind of corruption in
your forms. You can try recreating
the form (main or subform) from scratch or export them out into a new
database to see if it helps.

Regards,

Ki Yi
Microsoft Support

This posting is provided AS IS with no warranties, and confers no rights.


  #5  
Old October 12th, 2004, 07:17 PM
JC
external usenet poster
 
Posts: n/a
Default

Ki Yi,
Please accept my humble apology. I have gone back over the Northwind
database and it is in fact what I am trying to do. I have not done what you
suggested, but I am going to try it soon. Please check this thread out a
little later on and I will let you know what I find out and whether I will
need any further help. Thanks again for your time.
- jc -

"Ki Yi [MS]" wrote:

Hello,

Your code looks fine. It possible that this problem is specific to that
particular form due to corruption.
Open the Orders form in the Northwind sample database and copy/paste the
following code:

If Me.[Orders Subform].Form![ExtendedPrice] 100 Then
Me![Freight label].Visible = False
Else
Me![Freight label].Visible = True
End If

If above code works then most likely there's some kind of corruption in
your forms. You can try recreating
the form (main or subform) from scratch or export them out into a new
database to see if it helps.

Regards,

Ki Yi
Microsoft Support

This posting is provided AS IS with no warranties, and confers no rights.


  #6  
Old October 12th, 2004, 07:49 PM
JC
external usenet poster
 
Posts: n/a
Default

Ki Yi,
I keep getting a runtime error when I try to send you a reply and that is
why you have gotten two additional posts. I have looked at what you told me
to do and if you make one change to your suggestion, it is exactly what I am
trying to do and the Northwind Database is exhibiting the same behaviour as
my database is.
In the OnCurrent event on the Orders form I put the code you told me to. I
have commented out your If statement and below it is mine. Stepping through
this code, the [Freight label] will be visible and not visible as expected,
but when you "run" the code the freight label is ALWAYS visible.

I sure do hope that you can tell me why. :-)

Thanks
- jc -

Private Sub Form_Current()
' If Me.[Orders Subform].Form![ExtendedPrice] 100 Then
If [Orders Subform].[Form]![OrderSubtotal] 500 Then
Me![Freight label].Visible = False
Else
Me![Freight label].Visible = True
End If
End Sub


"Ki Yi [MS]" wrote:

Hello,

Your code looks fine. It possible that this problem is specific to that
particular form due to corruption.
Open the Orders form in the Northwind sample database and copy/paste the
following code:

If Me.[Orders Subform].Form![ExtendedPrice] 100 Then
Me![Freight label].Visible = False
Else
Me![Freight label].Visible = True
End If

If above code works then most likely there's some kind of corruption in
your forms. You can try recreating
the form (main or subform) from scratch or export them out into a new
database to see if it helps.

Regards,

Ki Yi
Microsoft Support

This posting is provided AS IS with no warranties, and confers no rights.


 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to RTF very slow when code is present in Access report. [email protected] Setting Up & Running Reports 11 September 14th, 2004 08:17 PM
sending same data to multiple noncorresponding cells rclark General Discussion 13 September 13th, 2004 06:49 PM
Conversion of excel vba code to access vba filnigeria General Discussion 5 July 15th, 2004 02:23 AM
customizing "documentor" output W Garrard Database Design 12 May 24th, 2004 03:07 AM


All times are GMT +1. The time now is 11:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.