By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,087 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

Code Check Please

P: 67
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.Visible = True
Me.Total15.Visible = True
Me.Vat.Visible = False
Me.TotalCost.Visible = False
Else
If Me.DateOfSale <= 1 / 12 / 2008 Then
Me.Vat15.Visible = False
Me.Total15.Visible = False
Me.Vat.Visible = True
Me.TotalCost.Visible = True
End If
End If

End Sub
Dec 3 '08 #1
Share this Question
Share on Google+
2 Replies


FishVal
Expert 2.5K+
P: 2,653
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:

Expand|Select|Wrap|Line Numbers
  1. 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;
  2.  
Regards,
Fish
Dec 3 '08 #2

P: 67
Thanks fish, i will try that.

Regards
Dec 3 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.