Case Statements problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KrazyKasper
    New Member
    • Mar 2008
    • 11

    Case Statements problem

    I really appreciate any help you can provide. Although I am only vaguely familiar with VBA I think my problem has to do with the way I am naming things or the “Select Case” statement in my code.

    In my report:
    The text box is named txt_MyPrice
    The Control Source is =mod_CreditItem ()

    In my code:
    The name of the (Standard?) Module is mod_CreditItem

    In the database:
    The table that houses the data is dbo_InvoiceDeta il (accessed via ODBC)
    The fields in the table are named: BillingType and ExtPrice

    When using the following code the report asks me to input data for that module name, when in fact it should get the fields from the database table; modify them as per the Case and Case Else Statements and display them in the report.

    Following is my current code:


    Option Compare Database

    Public Function mod_CreditItem( )

    Dim ShippingFactor As Integer

    Select Case dbo_InvoiceDeta il.BillingType

    Case "RE", "G2", "S1", "ZLG2", "ZZSA", "ZZG2", "ZZSR"

    ShippingFactor = -1

    Case Else

    ShippingFactor = 1

    End Select

    mod_CreditItem = dbo_InvoiceDeta il.ExtPrice * ShippingFactor

    End Function


    Thanks for your help.

    Krazy (Bill) Kasper
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    Before addressing anything else, you need to change the name of your standard module! You cannot name the function and the module that holds it mod_CreditItem. This confuses the Access Gnomes no end, and results in a number of different errors being thrown, depending on how the function is called. Change the module name to something else, and see if that fixes the problem.

    Welcome to the Bytes!

    Linq ;0)>

    Comment

    Working...