Results 1 to 6 of 6

Thread: [RESOLVED] #Error message appear in textbox Amount

  1. #1

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Resolved [RESOLVED] #Error message appear in textbox Amount

    Hi!!!


    I have a textbox in my subform called amount based on a query that computes for the amount...However when I type the product code in my subform, a #error will appear in the amount textbox..However when I press the tab key and enter the quantity ordered, the [#error] will be removed and the correct computation for the amount will be displayed on the textbox...


    How do I make the #error message disappear? Even if the user has not typed any quantity ordered....

    Im using ms access 2000/2003..

    Thanks

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: #Error message appear in textbox Amount

    Sounds like your missing some code in the product code textbox change event and you only have code in the OnExit event which is why it works?
    Can you post your code?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: #Error message appear in textbox Amount

    Hi RobDog888,

    I havent done any code yet....Actually, in the query OrderDetails Design View

    Here is the formula to compute the amount:

    Amount: CCur(Products.Product_Price*[Quantity_Ordered]*(1-[Discount])/100)*100

    I assume that the amount variable will compute a null value from any of the variables involved...Since the user has not typed any quantity yet, I assume that Quantity, Product_Price, and Discount has null/zero values...

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: #Error message appear in textbox Amount

    Correct. But instead of a nullstring value in the textbox it displays the #Error instead by design.

    Where do you have the code? in which property or procedure.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: #Error message appear in textbox Amount

    Actually,

    I have just started a little...

    Here is the vba code for my subform.

    VB Code:
    1. Private Sub Product_ID_AfterUpdate()
    2.     Form_ShortTermSalesDetailForm.Quantity_Ordered.Value = 1
    3. End Sub
    4.  
    5. Private Sub Product_ID_BeforeUpdate(Cancel As Integer)
    6.     Me.Quantity_Ordered.Value = 0
    7.     Me.Amount.Visible = False
    8. End Sub
    9.  
    10. Private Sub Product_ID_Change()
    11.     Me.Amount.Value = 0
    12. End Sub
    13.  
    14. Private Sub Quantity_Ordered_AfterUpdate()
    15.     Me.Amount.Visible = True
    16. End Sub

    My problem is when I set the Default value of every textbox to zero, MS Access will generate an error since the fields cannot be updated...

  6. #6

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: #Error message appear in textbox Amount

    Hi RobDog888,

    I just figured it out....I just added a new field in my ShortTermSalesDetail Table called Product_Price...This will receive the value from the table products field called product price...I substituted the formula of my query

    from this:

    Amount: CCur(Products.Product_Price*[Quantity_Ordered]*(1-[Discount])/100)*100

    to this:

    Amount: CCur([ShortTermSalesDetail].[Product_Price]*[Quantity_Ordered]*(1-[Discount])/100)*100

    The difference is that the first formula uses the price directly from the Products table while the second formula uses an ordinary field name that will receive the value from Products.Product_Price...

    So I guess thats where the #error message came from...Since Products.Product_Price can't have the default value zero since is bound to the Products Table..

    Then I put an ado code for ShortTermSalesDetail].[Product_Price to receive the value of Products.Product_Price.

    Here is the code:


    VB Code:
    1. Do While rstitem.EOF <> True
    2.        If itemcode = rstitem.Fields("Product_ID") Then
    3.                            
    4.        Me.ShortTermSalesDetail_Product_Price = rstitem.Fields("Product_Price")
    5.                            
    6.       End If
    7.       rstitem.MoveNext
    8.  Loop

    By the way, are there any websites concerned with pure VBA development(codes,tutorials...and etc...? I am already using MSDN and functionx.com...Thanks in advance.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width