473,324 Members | 2,581 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,324 software developers and data experts.

Help!! Table Field References

Hi all, I'm trying to create a function for my Access 2003 database.

Function RelativeStatus()
Dim Present As Double
Dim Past As Double

Present = [tblFleetRecent]![Actual]
Past = [tblFleetRecent]![LastWeek]

If Present > Past Then
RelativeStatus = "increase"

ElseIf Present = Past Then
RelativeStatus = "static"

ElseIf Present < Past Then
RelativeStatus = "decrease"

End If
End Function


It generates an error saying "external name not defined" highlighting [tblFleetRecent].
I tried putting [Tables]! infront of it but it didn't work
How do I reference these table fields???
Jan 23 '07 #1
1 912
MMcCarthy
14,534 Expert Mod 8TB
Hi all, I'm trying to create a function for my Access 2003 database.

Function RelativeStatus()
Dim Present As Double
Dim Past As Double

Present = [tblFleetRecent]![Actual]
Past = [tblFleetRecent]![LastWeek]

If Present > Past Then
RelativeStatus = "increase"

ElseIf Present = Past Then
RelativeStatus = "static"

ElseIf Present < Past Then
RelativeStatus = "decrease"

End If
End Function


It generates an error saying "external name not defined" highlighting [tblFleetRecent].
I tried putting [Tables]! infront of it but it didn't work
How do I reference these table fields???
You cannot refer to a table in a function like this. Assuming you want this value based on a particular record in the table then the values in those fields would have to be passed to the function as parameters. Where are you trying to use this function?

Expand|Select|Wrap|Line Numbers
  1. Function RelativeStatus(Actual As Double, LastWeek As Double) As String
  2. Dim Present As Double
  3. Dim Past As Double
  4.  
  5.    Present = Actual
  6.    Past = LastWeek
  7.  
  8.    If Present > Past Then
  9.       RelativeStatus = "increase"
  10.    ElseIf Present = Past Then
  11.       RelativeStatus = "static"
  12.    Else
  13.       RelativeStatus = "decrease"
  14.    End If
  15.  
  16. End Function
  17.  
Jan 24 '07 #2

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

Similar topics

3
by: vool | last post by:
Hi All Can anyone help with this please. I need a way of putting say 10 to 20 bullet points in one table field in an Access database - say seperate them with a special character, then build a...
1
by: Laetitia Clark | last post by:
Hi All I have a number of tables which have Text fields. I need to change the AllowZeroLength property value to True for all of them. Does anyone have some code which will do this for me ?...
4
by: Onion | last post by:
This has to be simple, but I'm forced to admit that I'm a novice who can't figure it out. I have a listbox in a form that allows multiple selections. That works fine. The problem: I can't...
10
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued...
2
by: Greg Strong | last post by:
Hello All, Is it possible to change table field lookup properties in code? I've been able to change other field properties in code, however so far no luck with field lookup properties. What...
2
by: mukesh | last post by:
Can we use expression in default value for a table field for example – IIf(Table-1.field-1=table-2 . field-1, table-1.field-2, 0) Interpretation – If field-1 of table -1 is like/equal to...
2
by: King Ron | last post by:
Ola all. In responding to a recent post requesting help with a search issue, I recommended using a combo box lookup in the table design. "paii, Ron" (no relation) posted this reply: " There are...
3
by: adiel_g | last post by:
Hello everyone, I am trying to move a field name to a variable in vb.net. For example, first I retrieve the record from the database and save its value: .... userGroup =...
2
by: timleonard | last post by:
How do you reference the Table:Field to use in a file path? I have been trying the code below I would like to reference a Tablel:Field to use in the path instead of hard coding the file name,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.