Results 1 to 3 of 3

Thread: vba error help

  1. #1
    Join Date
    May 2006

    Unanswered: vba error help

    I am using Access 2002 to build a database for a water company. I have a form for filling out the billing information (current tap reading, last tap reading, etc.) and then it calculates the total bill. I want to keep track of each months reading in a separate table (with fields CustomerID, JanReading, FebReading, etc). But to do that each time I enter a new bill I have to have code something like this (I think):

        DoCmd.OpenForm "frmBill"
        DoCmd.OpenForm "frmMonthlyReadings"
        Select Case Forms!frmBill!frmDate!Month.Text
            Case "January"
                [PresentReading] = Forms!frmMonthlyReadings!JanReading
            Case "February"
                [PresentReading] = Forms!frmMonthlyReadings!FebReading
            Case "March"
                [PresentReading] = Forms!frmMonthlyReadings!MarReading          
            Case "April"
                [PresentReading] = Tables!tblMonthlyReadings!AprReading
        End Select
    Okay so that seems like it should work, but it gives me an error "The expression you entered refers to an object that is closed or doesn't exist."
    It highlights line 10 of the code if the month is March. Is there a better way to do it? Hopefully this makes since. If not let me know. Thanks in advance.

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    does the control MarReading exist in form frmMonthlyReadings?

    I don't really understand what you are doing, I think I understand what you wnat to do, but your physical design doens't make much sense to me....
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    May 2005
    Nevada, USA
    Provided Answers: 6
    I agree with Mark. In my view, the fields JanReading... are not normalized, and a bad idea. What are you going to do next year? I think your table should contain fields for customer, date and the meter reading. For the current bill, you would pick up the current reading and the previous reading for that customer and compare them.

Posting Permissions

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