GetListPrice error in OrderDetailsExtended form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dinnydannydong
    New Member
    • Sep 2013
    • 9

    GetListPrice error in OrderDetailsExtended form

    Hi,

    I have a set up an OrderDetailsExt ended subform on an Order Form. I have used OrderDetailsExt ended Query, these were both taken from the Northwind Database. On productID I have adjusted the VBA in the after update. But I am still getting an error when I add a new product to the order.
    Code:
    Private Sub CustPrice_AfterUpdate()
    Private Sub ProductID_AfterUpdate()
        'Initialize price and discount for each product change
        If Not IsNull(Me![ProductID]) Then
            Me![Quantity] = 0
            Me.Quantity.Locked = False
            Me![CustPrice] = GetListPrice(Me![ProductID])
            Me![Discount] = 0
           
    End Sub
    The GetListPrice is being highlighted in blue and I can not see how this is related to anything.

    Any Help will be appreciated

    warm wishes

    Martin
    Attached Files
    Last edited by Rabbit; Oct 10 '13, 03:17 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    1. You cannot have two Sub-Routine Declarations withing the same Procedure as you have.
      Code:
      Private Sub CustPrice_AfterUpdate()
      Private Sub ProductID_AfterUpdate()
    2. GetListPrice() must be a 'Public' Function in a Standard Code Module.

    Comment

    • Dinnydannydong
      New Member
      • Sep 2013
      • 9

      #3
      Hi Thanks for getting back to be, I presume I remove the line
      Private Sub CustPrice_After Update()as I am working in the ProductID field.

      In regards to the second part I do not have GetListPrice in my Products table I have CustPrice as the field I want to match to. Could you explain how I do this. Thank you for your help

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        1. Post the Code for GetListPrice().
        2. What is the exact Error you are getting for a new Order?
        3. The Code you are referring to is in the AfterUpdate() Event of the Product ID Field in the Orders Subform, correct?
        Last edited by ADezii; Oct 10 '13, 02:51 PM. Reason: Additional Request

        Comment

        • Dinnydannydong
          New Member
          • Sep 2013
          • 9

          #5
          Code:
          Private Sub ProductID_AfterUpdate()
          
                If Not IsNull(Me![ProductID]) Then
                  Me![Quantity] = 0
                  Me.Quantity.Locked = False
                 Me![CustPrice] = GetListPrice(Me![Product ID])
                  Me![Discount] = 0
          
                 
          End Sub
          That is the code you requested in number 1.
          It came from where you described it in number 3.

          The error message I am getting is compile error sub or function is not defined and the top of the codeis in yellow and the GetListPrice is in blue.

          Thanks for all your help,

          Martin
          Attached Files
          Last edited by Rabbit; Oct 10 '13, 03:18 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.

          Comment

          • Dinnydannydong
            New Member
            • Sep 2013
            • 9

            #6

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              1. There is no [CustPrice] Field in the Record Source for the Sub-Form, Order Details Extended.
              2. You have a Space in the Argument ([ProductID]) to the Function Call where there should be none:
                Code:
                Me![CustPrice] = GetListPrice(Me![Product ID])
                should be:
                Code:
                Me![CustPrice] = GetListPrice(Me![ProductID])

              Comment

              Working...