473,395 Members | 1,411 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,395 software developers and data experts.

DLookup based on combo box on parent form

Hello everyone. I have a problem with looking up pricing. Here is
what I have so far:

TABLES

tblItems:
itemid
itemdescription
itemunit (each, roll, square foot)
location1price
location2price

tblOrders:
OrderID
JobName
PickUpLocation ( location 1 or location 2)

tblOrderDetails:
OrderID
Item
itemunit
Unit Price

I have a form set up for Orders (parent form) with Order Details as the
subform. The table "tblOrderDetails" is used for the subform. The
"Item" field is setup as a combo box on the form. An after update
procedure has been added to lookup information from the "tblItems"
table. Based on "itemid" it will fill in itemdescription, itemunit and
unit price. This all works fine.

The problem I have is picking the right price. If the "pick up
location" on the parent form is set to "location1", I need the unit
price on the subform to pull "location1pricing" from tblItems. If the
pick up location is set to "location 2", I need the unit price to pull
"location2pricing".

The code I have to pull pricing is:
Me.UnitPrice = DLookup("UnitPriceLocation1", "tblItems", "itemno=" &
Me.Description)
Of course, this always pulls in unitpricelocation1 pricing.
I tried an "IIf" with the "DLookup" but couldn't get it to work
properly. I also didn't think this was the best way to go with the
code.

Me.UnitPrice = IIf(Forms![frmquoteinformation].[FOB] =
unitpricelocation1, DLookup("unitpricelocation1", "tblItems", "itemno="
& Me.Description), DLookup("unitpricelocation2", "tblItems", "itemno="
& Me.Description))

This seems to always pull "unitpricelocation2" pricing.

Any help would be appreciated.

Jun 1 '06 #1
2 2576
c.kurutz wrote:
Hello everyone. I have a problem with looking up pricing. Here is
what I have so far:

TABLES

tblItems:
itemid
itemdescription
itemunit (each, roll, square foot)
location1price
location2price

tblOrders:
OrderID
JobName
PickUpLocation ( location 1 or location 2)

tblOrderDetails:
OrderID
Item
itemunit
Unit Price

I have a form set up for Orders (parent form) with Order Details as the
subform. The table "tblOrderDetails" is used for the subform. The
"Item" field is setup as a combo box on the form. An after update
procedure has been added to lookup information from the "tblItems"
table. Based on "itemid" it will fill in itemdescription, itemunit and
unit price. This all works fine.

The problem I have is picking the right price. If the "pick up
location" on the parent form is set to "location1", I need the unit
price on the subform to pull "location1pricing" from tblItems. If the
pick up location is set to "location 2", I need the unit price to pull
"location2pricing".

The code I have to pull pricing is:
Me.UnitPrice = DLookup("UnitPriceLocation1", "tblItems", "itemno=" &
Me.Description)
Of course, this always pulls in unitpricelocation1 pricing.
I tried an "IIf" with the "DLookup" but couldn't get it to work
properly. I also didn't think this was the best way to go with the
code.

Me.UnitPrice = IIf(Forms![frmquoteinformation].[FOB] =
unitpricelocation1, DLookup("unitpricelocation1", "tblItems", "itemno="
& Me.Description), DLookup("unitpricelocation2", "tblItems", "itemno="
& Me.Description))

This seems to always pull "unitpricelocation2" pricing.

Any help would be appreciated.

Can you create a query and use that as the "table source" instead of a
table? You can specify the price to pick up from the query. You might
also want to check to see if FOB is empty/null. The query would select
the itemno,location, and price. If there were prices for both, you'd
get 2 records. Thus if someone selected Loc2 and there was only Loc1
you'd have 1 record and you could create an error check off of that.
Jun 1 '06 #2
"c.kurutz" <c.******@comcast.net> wrote in
news:11**********************@h76g2000cwa.googlegr oups.com:
Hello everyone. I have a problem with looking up pricing.
Here is what I have so far:

TABLES

tblItems:
itemid
itemdescription
itemunit (each, roll, square foot)
location1price
location2price

tblOrders:
OrderID
JobName
PickUpLocation ( location 1 or location 2)

tblOrderDetails:
OrderID
Item
itemunit
Unit Price

I have a form set up for Orders (parent form) with Order
Details as the subform. The table "tblOrderDetails" is used
for the subform. The "Item" field is setup as a combo box on
the form. An after update procedure has been added to lookup
information from the "tblItems" table. Based on "itemid" it
will fill in itemdescription, itemunit and unit price. This
all works fine.

The problem I have is picking the right price. If the "pick
up location" on the parent form is set to "location1", I need
the unit price on the subform to pull "location1pricing" from
tblItems. If the pick up location is set to "location 2", I
need the unit price to pull "location2pricing".

The code I have to pull pricing is:
Me.UnitPrice = DLookup("UnitPriceLocation1", "tblItems",
"itemno=" & Me.Description)
Of course, this always pulls in unitpricelocation1 pricing.
I tried an "IIf" with the "DLookup" but couldn't get it to
work properly. I also didn't think this was the best way to
go with the code.

Me.UnitPrice = IIf(Forms![frmquoteinformation].[FOB] =
unitpricelocation1, DLookup("unitpricelocation1", "tblItems",
"itemno=" & Me.Description), DLookup("unitpricelocation2",
"tblItems", "itemno=" & Me.Description))

This seems to always pull "unitpricelocation2" pricing.

Any help would be appreciated.


Me.UnitPrice = DLookUp(IIf(Forms![frmquoteinformation].[FOB]=1,
"tblItems","itemno= '" & Me.Description & "'")

--
Bob Quintal

PA is y I've altered my email address.
Jun 1 '06 #3

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

Similar topics

1
by: John Hargrove | last post by:
I am building a database to manage test samples in an environmental laboratory. I am learning Access as I go and don't know much about the programming aspects. I hope to make the application...
5
by: Kalvin Schroder | last post by:
I am fairly new to Access, and am trying to put together an invoice form. The main form in called InvoiceDetailFm. Source is the table InvoiceDetail and has invoice number, saleman, and CustID as...
4
by: thx606 | last post by:
Hello, I'm having problems figuring this one out. I have 2 combo boxes. The first one the user selects a professor then the second one they select a course and that works fine. Here is my...
5
by: favor08 | last post by:
I have a database and I am using a function that captures the shortname and displays it on the mainMenu screen. What I want to do is filter the information on the "past due" screen based on the...
3
by: Patrick A | last post by:
All, My form "FRM_Main" contains 2 subforms, each an instance of the form "FRM_Testators" The object name of instance 1 of the form is "SFRM_Clients". The object name of instance 2 of the form...
3
by: Constantine AI | last post by:
Hi can anybody help me with this problem? I have a customer order form with a sales order line subform. The subform contains products ordered by customers, each (wooden) product can come in two...
6
by: David Wright | last post by:
Hello Folks I am using Microsoft Access 2000 I would be grateful if someone could help me with “Dlookup”. I tried various methods of writing Dlookup and various events to trigger it, none of...
0
by: solargovind | last post by:
Hello, I have few problem with Dlookup condition. I need to retrieve next record or previous record based on certain condition. The conditions are set in in the combo box. Here, I am trying to...
23
by: dkotula | last post by:
Hello, I have a DB with linked tables to ODBC, and queries based on them. I have a form with 3 cascading combo boxes and tabs containing subforms. Along with the combo boxes on the main form I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
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,...
0
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...
0
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...

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.