Code Check Please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wayneyh
    New Member
    • Mar 2008
    • 67

    Code Check Please

    Hi all

    I am having trouble getting some code working. Would someone please check the following code and tell me why it doesn't work. If additional info is required please ask. Thanks.


    Private Sub Cost_Change()
    If Me.DateOfSale >= 30 / 11 / 2008 Then
    Me.Vat15.Visibl e = True
    Me.Total15.Visi ble = True
    Me.Vat.Visible = False
    Me.TotalCost.Vi sible = False
    Else
    If Me.DateOfSale <= 1 / 12 / 2008 Then
    Me.Vat15.Visibl e = False
    Me.Total15.Visi ble = False
    Me.Vat.Visible = True
    Me.TotalCost.Vi sible = True
    End If
    End If

    End Sub
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Hello, Wayneyh.

    What you are trying to implement seems to me very complicated, not flexible and not robust approach.
    Do you want to add a control to form and section to code each time VAT changes? Also, this approach will make you add conditions to queries totalling records and so on so on.

    Why not to make a table, let us say tblVAT with the following structure:

    keyVATID Autonumber(Long ), PK
    dteStart Date/Time
    dteEnd Date/Time
    sglVAT Number/Single

    Further you can join it with your table in the following manner:

    Code:
    SELECT [YourTable].Cost + [YourTable].Cost*(1+[tblVAT].[sglVAT]/100) AS CostAndVAT FROM [YourTable] INNER JOIN [tblVAT] ON [YourTable].dteSale<=[tblVAT].dteEnd AND [YourTable].dteSale>=[tblVAT].dteEnd;
    Regards,
    Fish

    Comment

    • Wayneyh
      New Member
      • Mar 2008
      • 67

      #3
      Thanks fish, i will try that.

      Regards

      Comment

      Working...