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
|
|||
|
|||
"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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |