473,657 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

use lookup field with non bound control

I'm not sure the subject line is a very clear description of my problem
so...

I have two relevant tables for this issue...
the lookup table tblLookupItems with three fields [description]
[DefaultCost] [DefaultPrice]. The control source for my form tblExpenses.
In this table there are three relevant fields [ItemDescription] [ItemCost]
[InvPrice].

On the form the [ItemDescription] field is set up as a combobox to get
values from tblLookupItems. These values however, are stored in tblExpenses
as text and are not linked to the lookup table. The form simply uses the
lookup table for possible items. The user of the form does not need to
select one of these items, they can type in there own. The rowsource for the
combo box is... SELECT DISTINCTROW [LookupItems].[Name],
[LookupItems].[DefaultCost] FROM [LookupItems]; LimitToList is set to No and
from the table definition Required is set to No. This works fine.

What I want to do, is when the user selects one of the item in the list,
have the data in the [DefaultCost] and [DefaultPrice] fields automatically
entered into [ItemCost] and [InvPrice] fields respectively as the default
values. Thus if the user selects Item A from the list, the [DefaultCost] and
[DefaultPrice] will be entered into [ItemCost] and [InvPrice] and no longer
be linked to tblLookupItems anymore. In other words, if tblLookupItems were
deleted, tblExpenses would show the following record:
Item A $4.00 $8.00

If this is unclear let me know and I will try to clarify.

Jimmy
Oct 9 '06 #1
3 3546
ray
Hi Jimmy,

For this to work, you will need to add the DefaultPrice to the
rowsource for the combobox. As in
SELECT DISTINCTROW [LookupItems].[Name], [LookupItems].[DefaultCost],
[LookupItems].[DefaultPrice] FROM [LookupItems]

Set the column width of the third column in the combobox to 0 if you
don't want the user to see it.

Then, try in the AfterUpdate event for the combobox:

me!ItemCost = me!ComboBoxName .Column(1)
me!InvPrice = me!ComboBoxName .Column(2)

Note that the column count is zero based, so the third column is
referred to as .column(2).

Ray


Jimmy wrote:
I'm not sure the subject line is a very clear description of my problem
so...

I have two relevant tables for this issue...
the lookup table tblLookupItems with three fields [description]
[DefaultCost] [DefaultPrice]. The control source for my form tblExpenses.
In this table there are three relevant fields [ItemDescription] [ItemCost]
[InvPrice].

On the form the [ItemDescription] field is set up as a combobox to get
values from tblLookupItems. These values however, are stored in tblExpenses
as text and are not linked to the lookup table. The form simply uses the
lookup table for possible items. The user of the form does not need to
select one of these items, they can type in there own. The rowsource for the
combo box is... SELECT DISTINCTROW [LookupItems].[Name],
[LookupItems].[DefaultCost] FROM [LookupItems]; LimitToList is set to No and
from the table definition Required is set to No. This works fine.

What I want to do, is when the user selects one of the item in the list,
have the data in the [DefaultCost] and [DefaultPrice] fields automatically
entered into [ItemCost] and [InvPrice] fields respectively as the default
values. Thus if the user selects Item A from the list, the [DefaultCost] and
[DefaultPrice] will be entered into [ItemCost] and [InvPrice] and no longer
be linked to tblLookupItems anymore. In other words, if tblLookupItems were
deleted, tblExpenses would show the following record:
Item A $4.00 $8.00

If this is unclear let me know and I will try to clarify.

Jimmy
Oct 9 '06 #2
"Jimmy" <no**@none.comw rote in
news:4I******** *******@fe04.ne ws.easynews.com :
I'm not sure the subject line is a very clear description of
my problem so...

I have two relevant tables for this issue...
the lookup table tblLookupItems with three fields
[description]
[DefaultCost] [DefaultPrice]. The control source for my form
tblExpenses. In this table there are three relevant fields
[ItemDescription] [ItemCost] [InvPrice].

On the form the [ItemDescription] field is set up as a
combobox to get values from tblLookupItems. These values
however, are stored in tblExpenses as text and are not linked
to the lookup table. The form simply uses the lookup table for
possible items. The user of the form does not need to select
one of these items, they can type in there own. The rowsource
for the combo box is... SELECT DISTINCTROW
[LookupItems].[Name], [LookupItems].[DefaultCost] FROM
[LookupItems]; LimitToList is set to No and from the table
definition Required is set to No. This works fine.

What I want to do, is when the user selects one of the item in
the list, have the data in the [DefaultCost] and
[DefaultPrice] fields automatically entered into [ItemCost]
and [InvPrice] fields respectively as the default values. Thus
if the user selects Item A from the list, the [DefaultCost]
and [DefaultPrice] will be entered into [ItemCost] and
[InvPrice] and no longer be linked to tblLookupItems anymore.
In other words, if tblLookupItems were deleted, tblExpenses
would show the following record: Item A $4.00 $8.00

If this is unclear let me know and I will try to clarify.

Jimmy
It's not unclear. In the combobox's AfterUpdate event, you want
a little VB code that takes the value of combobox column two and
puts that in the [ItemCost] field.

me![Itemcost] = me.combobox.col umn(1)
'NOTE: the column property is ZERO-based, the first column is 0,
the second is 1, the third is 2. PITA.

you'll also want to modify the combobox's rowsource to add the
third column, DefaultPrice, then you can add code to stuff its
value into the correct textbox of field.


--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Oct 9 '06 #3
Mucho Danke! My problem was I was trying to bring the tblLookupItems into
the query that was my record source for the form and it kept throwing off
one of the subforms.

thanks for the quick response guys.

Jimmy
Oct 10 '06 #4

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

Similar topics

3
2912
by: my-wings | last post by:
I've been reading about how evil Lookup fields in tables are, but I've got to be missing something really basic. I know this subject has been covered before, because I've just spent an hour or two reading about it on google, but there is something I still don't understand, and I'm hoping someone will be willing to explain it to me in small words. Let's say I have a table for addresses, and it includes a field for state. What I would...
3
1399
by: xmp333 | last post by:
Hi, Is there a way to use a 2 column table as a lookup for a combo box, having one field show up on the form, and the other field actually written to the output table? Here's an example: I have a reference table called "R" with the following values: { (0, 'Price'),
1
3357
by: James | last post by:
I am used to VB6 but need to develop something in .Net. I need to create several bound combo-boxes which will use lookup tables to get their values. I created a form using the dataform wizard. As part of the setup, I specified a new dataset, which included the data & lookup tables. I also specified the relationships when required. I then added a combo box control to my form, following the instructions from
4
4611
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
5
1500
by: Ryker | last post by:
I have a form that has name address, ect. The key is social security number. I have a lookup box where social security number is entered and the table is searched for a matching number. If there is a matching number, the record is displayed on the form. If there is no matching record, it is treated as a new record and I move onto the next field to start inputing the new info. The problem is that I have to input social security number...
2
7978
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 I've done for test purposes is use a text input file for the table field lookup properties. I thought that I'd start first by just changing the 'Display Control' property. Thanks to Allen Browne for some ideals per...
11
2645
by: Paul H | last post by:
Suppose I have a table called tblPeople and I want a field to illustrate whether each person prefers cats or dogs. I could do it one of three ways. 1. A plain text field Create a text field in tblPeople called PreferredPet. 2. A lookup field that stores text values. Create a text field in tblPeople called PreferredPetID and use it to lookup an identical text field in tblPreferredPets.
1
1755
by: Nestor01 | last post by:
I use a lookup table which contacts 2 fields (item#, name) When a customer places an order, the order form contains a drop down to select the item by name (from the lookup table). The detail is stored by item # in a customer order table. The form displays the name, but is column bound to the item#. When I want to create a report or form showing what the customer has ordered, I would like to display the name in a textbox control, but the...
14
6548
by: Mark | last post by:
I have a table with a field that uses a combobox to populate values. The Lookup tab within table design mode is the following: Display Control Combo Box Row Source Type Table/Query Row Source SELECT .LastName, .FirstName, .EmployeeNumber FROM ; Bound Column 3 Column Count 3 Column Heads Yes Column Widths 1";1";1"
0
8413
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8842
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5642
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.