473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

IF statment problem

Below is my code I'm new to coding and don't have much experience I get an error 424 when I try to run it any help would be welcome


Public Function vatty()

If Stocktbl.[Vat] = True Then
Stocktbl.[Total] = "Stocktb.[Price]*1.175"
Else
Stocktbl.[Total] = "Stocktbl.[Price]"
End If


End Function
Nov 7 '06 #1
7 1302
MMcCarthy
14,534 Expert Mod 8TB
Below is my code I'm new to coding and don't have much experience I get an error 424 when I try to run it any help would be welcome


Public Function vatty()

If Stocktbl.[Vat] = True Then
Stocktbl.[Total] = "Stocktb.[Price]*1.175"
Else
Stocktbl.[Total] = "Stocktbl.[Price]"
End If


End Function
Where are you calling this function?

Are you trying to access a table directly? You have to use recordsets for this.

What are you trying to do and where?
Nov 7 '06 #2
NeoPa
32,556 Expert Mod 16PB
The text of the error message would be helpful (as would the line it occurred on), but I think your problem is that you're trying to assign a string to a numeric variable. Try losing the quotes.
Nov 8 '06 #3
Got it sorted lads
Nov 9 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
Got it sorted lads
Just out of curiousity what was the problem?
Nov 10 '06 #5
NeoPa
32,556 Expert Mod 16PB
I'm a lad (if a little long in the tooth) but I'm not so sure about Mary.

PS I'm unashamedly 'Post-whoring' to get to 500 before going to bed tonight ;)

Seriously though, we're pleased to have helped.
Nov 10 '06 #6
MMcCarthy
14,534 Expert Mod 8TB
I'm a lad (if a little long in the tooth) but I'm not so sure about Mary.

PS I'm unashamedly 'Post-whoring' to get to 500 before going to bed tonight ;)

Seriously though, we're pleased to have helped.
Adrian

You whoreeee!!!

Congratulations....

Mary
Nov 10 '06 #7
PEB
1,418 Expert 1GB
Maybe you refer to a form... Form named Stocktb. Am i right?
So your code should be:
Expand|Select|Wrap|Line Numbers
  1. Public Function vatty()
  2.  
  3. If Forms!Stocktbl![Vat] = True Then
  4. Forms!Stocktbl![Total] = Forms!Stocktbl![Price]*1.175
  5. Else
  6. Forms!Stocktbl![Total] = Forms!Stocktbl![Price]
  7. End If
  8. vatty=true
  9.  
I've put vatty=true coz every function usually gives result... At least in maths is like this.. y=f(x)

Here you don't need of x, ok there is no pb for visual Basic... but seems you don't need from y neither??? For visual Basic no pb no more... But it seems if we don't need of y and x we don't need a function need it?

In fact all you do in your function can be done in your respective form!
If this is a table... he he sorry impossible... If you tell query -> there is solution but very vewry difficult for u i imagine coz lot of coding!

Below is my code I'm new to coding and don't have much experience I get an error 424 when I try to run it any help would be welcome


Public Function vatty()

If Stocktbl.[Vat] = True Then
Stocktbl.[Total] = "Stocktb.[Price]*1.175"
Else
Stocktbl.[Total] = "Stocktbl.[Price]"
End If


End Function
Nov 19 '06 #8

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

Similar topics

1
by: e_AK_05 | last post by:
I have a question and I can't figure out how to do it. I have a select statment : SELECT table1.* AS table1.*, table2.* AS table2.* FROM table1, table2 WHERE 1 this does not work...for me at...
1
by: Joe Saliba | last post by:
Hi, would like to know how to write a crosstable select statment in sql server2000 where having: - ItemNumber, ItemDescription, ItemColor, ItemSize as rows - Stores as columns - Qty * Netttc...
9
by: Appel | last post by:
Hallo i have a problem to add to string with a SQL statement. My Table : Tablename NAMES: | Name1 | Name2 | Name3 | John Meyer I search for a SQL statment that update Name3.
1
by: Maria | last post by:
Hello I have not used db2 in a long time, and I have this very long insert script, which is giving me an error of duplicated inserts. My question is how can I put something in the statment so...
1
by: Me, Myself, and I | last post by:
First off, i apologize if my terminology is off... I am currently in a project that is basically a front-end to a database. In coding this, I am taking into account that it has the *potential*...
5
by: orencs | last post by:
Hello, I am using Microsoft.Practices.EnterpriseLibrary.Data. I am running the following sqlCommand = "SELECT var1 FROM table1 WHERE var2 IN (4,5,6) ; SELECT var3 FROM table2 WHERE var2 IN...
5
by: vsteshenko | last post by:
Hello, This is my second post to the any usernet group and the first one was posted to the wrong one. I am currently working on creating an order form for sales associates at my work to be used...
4
by: huzzaa | last post by:
I am using a switch statement that will decide from a random number what message to display. I want the random number to be between 0 and 100 and then if the number is say between 1 and 10 to...
1
by: zeebiggie | last post by:
Good morning I have a form with the controls in the insert statment below. table1 has an Auto increment primary key hence is omitted in the insert statment and form. Am getting the error It didnt...
1
by: shivendravikramsingh | last post by:
hello friends, actually i have a problem in using conditional statement in ajax function i m tring to describe my problem properly,what i want when i select a value form a combo its vlue is passed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.