473,624 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I use an expression for a default value?

Please forgive me for using the wrong term here or there. I'm an old Excel 4
macro guy who didn't convert to VB and I'm tinkering with an Access 2000 DB.
I'm sure there is a simple Access 101 answer for this.

I have a subform which the user selects an item description from a combo box
from a table. I want to obtain the cost for the item (another field in the
table) also. I've been able to produce the second data field by rewriting
the syntax in the item combo box to include the cost field and using
different syntaxes to obtain the specific cost column in the separate field
on the subform. I have the data I need. Now the problem.

When the user finishes the item entries for the subform line and moves to a
new row on the form I want the Cost recorded as a part of the permanent
transaction record, not a linked value to the item cost. (which changes if
you edit the value on the item's cost table... the cost today is X and Y
tomorrow, I need X as a permanent record)

The individual sales transaction is recorded in a table. The item #, and
user entered Units and Price are recorded to the a transactions table. A
subtotal is a linked / calculated field in the transactions table also. I
want to record the COST as a hard value (like the user entered values) in
this table. I created a field called ProductCost to post the COST data into
in this transaction table.

How do I populate ProductCost in the transactions table with COST from the
subform? I've tried unsuccessfully to set the default value of the subform
ProductCost to 'COST' and set the Control Source to ProductCost of the
transactions table. If I enter a true value like 17 as a default value
that does post to transactions. Since 'expression builder' is available for
use with 'default value' it seems like I should be able to use an expression
instead of a hard value. I'm using a text box.

I again apologize for the terminology errors and would appreciate any help.

Thanks
Terry B

Nov 12 '05 #1
2 8216
terry, the problem you have encountered is that the default value
only gets pulled into the control when the first change is
entered (referred to as dirtying the record). Since the cost is
at that time still not defined, you'll have to use a different
event to trigger the writing of your cost. There are a few
different events you could use. The one I would use is probably
the combo box's AfterUpdate event. This event occurs when you
have selected a value from the list.

In the AfterUpdate property for the combo box, enter an
expression that writes the value from the combo box into the cost
field.

e.g. me!cost = me!cboItemDescr iption.column(x-1)
where cost is the name of the textbox control bound to the cost
field of your sales transaction record,, cboItemDescript ion is
the name of the combo box control that you pick from, and x is
the position of the column in the combo box, counting from the
left.

Bob Q

"Terry Bickle" <te****@cox.net > wrote in
news:%qjLb.3056 0$JD6.25308@lak eread04:
Please forgive me for using the wrong term here or there. I'm
an old Excel 4 macro guy who didn't convert to VB and I'm
tinkering with an Access 2000 DB. I'm sure there is a simple
Access 101 answer for this.

I have a subform which the user selects an item description
from a combo box from a table. I want to obtain the cost for
the item (another field in the table) also. I've been able to
produce the second data field by rewriting the syntax in the
item combo box to include the cost field and using different
syntaxes to obtain the specific cost column in the separate
field on the subform. I have the data I need. Now the problem.

When the user finishes the item entries for the subform line
and moves to a new row on the form I want the Cost recorded as
a part of the permanent transaction record, not a linked value
to the item cost. (which changes if you edit the value on the
item's cost table... the cost today is X and Y tomorrow, I
need X as a permanent record)

The individual sales transaction is recorded in a table. The
item #, and user entered Units and Price are recorded to the a
transactions table. A subtotal is a linked / calculated field
in the transactions table also. I want to record the COST as a
hard value (like the user entered values) in this table. I
created a field called ProductCost to post the COST data into
in this transaction table.

How do I populate ProductCost in the transactions table with
COST from the subform? I've tried unsuccessfully to set the
default value of the subform ProductCost to 'COST' and set the
Control Source to ProductCost of the transactions table. If I
enter a true value like 17 as a default value that does
post to transactions. Since 'expression builder' is available
for use with 'default value' it seems like I should be able to
use an expression instead of a hard value. I'm using a text
box.

I again apologize for the terminology errors and would
appreciate any help.

Thanks
Terry B



Nov 12 '05 #2
Bob:

Thanks again for taking the time to decipher my problem. I was able to
interpolate and apply your suggestion successfully!

Thanks again!
Terry

"Bob Quintal" <bq******@gener ation.net> wrote in message
news:71******** *************** *******@news.te ranews.com...
terry, the problem you have encountered is that the default value
only gets pulled into the control when the first change is
entered (referred to as dirtying the record). Since the cost is
at that time still not defined, you'll have to use a different
event to trigger the writing of your cost. There are a few
different events you could use. The one I would use is probably
the combo box's AfterUpdate event. This event occurs when you
have selected a value from the list.

In the AfterUpdate property for the combo box, enter an
expression that writes the value from the combo box into the cost
field.

e.g. me!cost = me!cboItemDescr iption.column(x-1)
where cost is the name of the textbox control bound to the cost
field of your sales transaction record,, cboItemDescript ion is
the name of the combo box control that you pick from, and x is
the position of the column in the combo box, counting from the
left.

Bob Q

"Terry Bickle" <te****@cox.net > wrote in
news:%qjLb.3056 0$JD6.25308@lak eread04:
Please forgive me for using the wrong term here or there. I'm
an old Excel 4 macro guy who didn't convert to VB and I'm
tinkering with an Access 2000 DB. I'm sure there is a simple
Access 101 answer for this.

I have a subform which the user selects an item description
from a combo box from a table. I want to obtain the cost for
the item (another field in the table) also. I've been able to
produce the second data field by rewriting the syntax in the
item combo box to include the cost field and using different
syntaxes to obtain the specific cost column in the separate
field on the subform. I have the data I need. Now the problem.

When the user finishes the item entries for the subform line
and moves to a new row on the form I want the Cost recorded as
a part of the permanent transaction record, not a linked value
to the item cost. (which changes if you edit the value on the
item's cost table... the cost today is X and Y tomorrow, I
need X as a permanent record)

The individual sales transaction is recorded in a table. The
item #, and user entered Units and Price are recorded to the a
transactions table. A subtotal is a linked / calculated field
in the transactions table also. I want to record the COST as a
hard value (like the user entered values) in this table. I
created a field called ProductCost to post the COST data into
in this transaction table.

How do I populate ProductCost in the transactions table with
COST from the subform? I've tried unsuccessfully to set the
default value of the subform ProductCost to 'COST' and set the
Control Source to ProductCost of the transactions table. If I
enter a true value like 17 as a default value that does
post to transactions. Since 'expression builder' is available
for use with 'default value' it seems like I should be able to
use an expression instead of a hard value. I'm using a text
box.

I again apologize for the terminology errors and would
appreciate any help.

Thanks
Terry B


Nov 12 '05 #3

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

Similar topics

23
3220
by: Paul Rubin | last post by:
OK, I want to scan a file for lines matching a certain regexp. I'd like to use an assignment expression, like for line in file: if (g := re.match(pat, line)): croggle(g.group(1)) Since there are no assignment expressions in Python, I have to use a temp var. That's a little more messy, but bearable:
25
2379
by: Steven Bethard | last post by:
So I end up writing code like this a fair bit: map = {} for key, value in sequence: map.setdefault(key, ).append(value) This code basically constructs a one-to-many mapping -- each value that a key occurs with is stored in the list for that key. This code's fine, and seems pretty simple, but thanks to generator
5
2514
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL, and then reconstruct another URL based on it. For example, I need to scan a web page looking for something like <a href="some_dir/list_20050815100225.csv">. I don't know in advance what the date/time in the file name will be. I need to take the...
1
1422
by: Earthling | last post by:
I want to enter an expression into my Default Value under my field properties within the design view of my table. In English: If the previous record has the same "product ID" number then by default make the result FALSE, otherwise TRUE for the given field name value. What this does is compare the previous Product ID (data type is Number) -
18
9028
by: Steve | last post by:
Hi I have a really weird problem and any assistance would be welcome. I have developed an app in Access 2002. The app runs perfectly on the development machine. I have packaged the app using the Microsoft XP Developer Packaging Wizard (Service Pack 1). The 1st 3 releases of the app ran perfectly on site.
8
1424
by: Leon | last post by:
My web application allow the user to enter the site by typing in a subdomain such as 'name.domain.com'. However, I want to retrieve just the 'name' part of the subdomain. see code below (the equal sign '=' respresent the value I'm getting when I run the code) Test 1.........................name.domain.com Dim sdmlink As String = Request.Url.ToString
10
4574
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a zero-length string (always returns a zero-length string when used in a query expression)" **** How many records are there in FirstTable in which Product Is Null. SELECT COUNT(*) AS CountofNullProdcut
37
2611
by: gardenfrogs | last post by:
I have fields in a table that include dates of meetings, phone calls, mailings, and other contact with clients. I have one field that is "most recent contact date". I want that default value to be the most recent date among all the types of contacts. How would I build this expression in the default value area of the table? I basically need something that will return the most recent date among 5 fields. Thanks!
1
3386
by: NvrBst | last post by:
I want to use the .replace() method with the regular expression /^ %VAR % =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)" regular expression with "": --------------------------------- myStringVar = myStringVar.replace("^" + iName + "=,($|&)", ""); --------------------------------- The following DOES replace it though: --------------------------------- var match = myStringVar.match("^" + iName + "=,($|&)");
0
8231
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
8168
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8672
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
8330
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,...
1
6107
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
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
4075
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
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1780
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.