So...I've wrote up a block of code calculating the total charge of a sale. However, it doesn't seem to be working, as whenever I try running the form, MS Access returns with a: Runtime error '2465' - System can't find the field '|1' referred to in your expression.
The below is my code - it's pretty self explanatory, but I'd be happy to run you through each line if it's hard to understand: - Private Sub Form_Current()
-
Dim AdultPrice As Integer
-
Dim ChildPrice As Integer
-
Dim InfantPrice As Integer
-
Dim AdultsPrice As Integer
-
Dim ChildrenPrice As Integer
-
Dim InfantsPrice As Integer
-
Dim BaseRatePrice As Integer
-
Dim BaseMultiplier As Integer
-
Dim AccommodationType As String
-
Dim Duration As Integer
-
-
If Me.Peak_Period.Value = "Yes" Then
-
AdultPrice = DLookup("BaseRate", "Base Rates", "Label = '" & "Adult - Peak" & "'")
-
ChildPrice = DLookup("BaseRate", "Base Rates", "Label = '" & "Child - Peak" & "'")
-
Else
-
AdultPrice = DLookup("BaseRate", "Base Rates", "Label = '" & "Adult" & "'")
-
ChildPrice = DLookup("BaseRate", "Base Rates", "Label = '" & "Child" & "'")
-
End If
-
-
InfantPrice = DLookup("BaseRate", "Base Rates", "Label = '" & "Infant" & "'")
-
-
AdultsPrice = [Me.Adults.Value] * AdultPrice
-
ChildrenPrice = [Me.Children.Value] * ChildPrice
-
InfantsPrice = [Me.Infants.Value] * InfantPrice
-
-
BaseRatePrice = AdultsPrice + ChildrenPrice + InfantsPrice
-
AccommodationType = DLookup("AccommodationType", "Accommodations", "Accommodation ID = '" & Me.Accommodation.Value & "'")
-
BaseMultiplier = DLookup("BaseMultiplier", "Accommodation Types", "Label = '" & AccommodationType & "'")
-
Duration = DateDiff("d", [Arrival Date], [Departure Date]) + 1
-
-
Me.Charge.Value = BaseRatePrice * BaseMultiplier * Duration
Thanks!
You should drop the brackets in your control references...
AdultsPrice = [Me.Adults.Value] * AdultPrice
should be:
AdultsPrice = Me.Adults.Value * AdultPrice
etc.. for the other similar lines.
2 3014
What line of code does it fail on? (ie: which line is highlighted when you click the 'Debug' button in the error message popup?)
You should drop the brackets in your control references...
AdultsPrice = [Me.Adults.Value] * AdultPrice
should be:
AdultsPrice = Me.Adults.Value * AdultPrice
etc.. for the other similar lines.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JMCN |
last post by:
hello
i receive a runtime error '2465' whenever i run my module in access
97. it says
'Run-time error '2465'
OOB Reports can't find the field "DuplicatePayments' referred to in
your...
|
by: MLH |
last post by:
"The following unexpected error occurred in Sub CopyMySQLbttn_Click,
line #250, CBF on frmVehicleChooserform. 2465: "Can't find the field
'forms' referred to in your expression. You may have...
|
by: Bruce Skamser |
last post by:
I added a field to a table and when I go to the form to add a textbox
control, I can't bind it to the field in the table. It doesn't come up in
the list of fields in the control source dropdown. ...
|
by: PW |
last post by:
Hi,
What the heck is that supposed to mean? I am getting this error on a
"Me.Requery" line in a subroutine on a form, but only when I select
something from a combo/dropdown box. The *exact*...
|
by: chris |
last post by:
I have a form that is labeled Document Control. On this form it calls
an API Function to browse for a folder, puts its in to the text box
and allows you to create a table out of the folders...
|
by: imrosie |
last post by:
hello experts,
Im a newbie in need of someone's experience. I have an image repository db that allows the input and search images just fine. However, if I want to erase an image, the subroutine...
|
by: ontherun |
last post by:
hi,
i have two forms CHS_Customer and 'CHS_Job'
both have a common field, "Company_Name"
i want to open the form 'CHS_Job' from the form 'CHS_Customer ' and when i open, the Company_Name field...
|
by: kcdoell |
last post by:
Hello:
I have the following afterupdate event:
Private Sub GWP_AfterUpdate()
'Updates the Total calculation in the control "SumGWP" on the quick reference
'table that is located on the form...
|
by: Andrew Hulting |
last post by:
I am getting an erro on line 11, OpenDatabase(Name As String, , , ) I can leave the Options field blank, and it errors saying that the password is invalid, I am 100% certian that the password is...
|
by: Ian Strawser |
last post by:
class Encrypt(object):
#The worst object ever created
def __init__(self,alphabet):
self.alphabet = alphabet
self.trans = self.maketrans()
self.count = -1
...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |