473,513 Members | 3,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Array in Dlookup

Hi,
I'm trying to lookup a price (CstLB) that match the part number
(Part1-11)
on the form and assign it to variable "Cost". I have 11 txtR (txtR1,
txtR2,...) and 11 txtWeight (txtW1, txtW2....)
The result of "Cost" is multiplied by the appropiate txtWeight (1-11) .
First I asked only loop through the Part number that only contain data.
Then
perform the Dlookup, calculate the "FinalCost" and place the result in
the
appropiate textbox (txtBx1, txtBx2, txtBx6....) The code I tried below
is
not working.

Private Sub Calculate_Click()

Dim i As Integer
Dim cost As Currency
Dim PartNo as String
Dim Weight as double, FinalCost as double

PartNo = Me("Part" & CStr(i))
Weight=Me("Wt" & Cstr(i))

For i = 1 To 11
If Not IsNull(PartNo) then
Me("Part" & CStr(i)).SetFocus
Cost=DLookup("[CstLB]", "RawIngredients", "[ID]=PartNo")
FinalCost=Cost* Weight
Me("txtBx" & Cstr(i))=FinalCost
End If

Next i

End Sub
Thank you

PJ

Nov 13 '05 #1
1 3887
Ouch that looks like a lot of work. Why not have a main form for your
bid/invoice whatever, and then put all the parts/raw ingredients in the
subform. then you can just use a domain or domain aggregate function
for your final cost...

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5154
by: Bobbak | last post by:
Hello All, I am having trouble with this forum I am developing, I have this form that allows the users to add or modify employee information, and there's a text box called txtEmployeeLogin, and this connected to the field EmpLogin in the database table. Now this field is not a Key field and it is not required, and not all employees have...
6
1543
by: Deano | last post by:
I think my brain has short-circuited again :) Is this the quickest way to check for the existence of a given value in an array? e.g For i = 0 To rrst.RecordCount If myArray(i) = DLookup("ID", "tblmain", "Salary = " & varSomeValue) Then
5
1893
by: Iain Miller | last post by:
Trying to get my head round building a DB to analyse phone bills. On the surface its fairly simple - duration in seconds x cost per minute/60. The problem arises with working out what time of day a call was made because calls are charged at different rates at different times. The problem with this is working out when a call crosses time...
8
4305
by: Christine Henderson | last post by:
I have a problem using the above function in the following simplified circumstance: In the lookup table called "Klms Travelled" I have 3 fields, eg: Receiver Name Receiver Suburb Klms Distance Jones Melbourne 500 Harrison Sydney ...
2
1513
by: Deano | last post by:
God knows I've had my run-ins with arrays but this problem is really killing me! I'm looping through a recordset. For each record I need to look at a field value and then see if it exists in a 2D array. It could be any one of the values in the array and they are not in a particular order. I don't think there's a built-in way of doing...
4
8663
by: jpr | last post by:
Hello, I have created menu bars for my access application and now would like to transfer many pieces of code in modules so that they can run using macros. I beleive this is the only way I can make run my code from the menu bar. Correct? I am having problems with the modules since I have never used them and would like some help.
2
2841
by: jonvan20 | last post by:
I have been having trouble with a simple Dlookup command that was Reccommended to me by a nice fellow named Vic, On the other hand I have statements like this that wont run they give me a run time error Dim QuoteNumber As String QuoteNumber = Me.txtQuoteNumber Me.txtDealerNumber = DLookup("Dealer_Number", "Quote Table",...
7
6806
by: supertsik | last post by:
Hi After a lot of research I didn't manage to solve the following problem: I have a table called 'Autos' with fields , , 1 ¦ Mike ¦ BMW 2 ¦ Mike ¦ Ford 3 ¦ Mike ¦ Toyota 4 ¦ Nick ¦ Audi
3
2433
reginaldmerritt
by: reginaldmerritt | last post by:
I'm using Dlookup to search a table for the first record it comes across that has a date >= the date i specifiy. e.g. formateddate = format(Me.SelectedDate,"mmddyy") VarX = DLookup("", "tbChargeRate", " >= #" & formateddate & "#") The problem i have is that there maybe several records in tbChargeRate that have PKDateField >...
0
7178
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7125
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3252
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.