473,662 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Field value change on data entry in another field

6 New Member
Hi there ppl, I hope you guys can help me.

I have two fields: [Haulier Invoice Number] and [POD Status]. I've set the POD status' default value as "Awaiting". There are only 2 possible values: "Awaiting" and "Recieved". What I'd like to do is: If the [Haulier Invoice No] is empty the [POD Status] should be "Awaiting". But if [HIN] gets a value [POD S] should change to "Recieved Automatically.

Please guys I really need help.

Thanx
Oct 27 '08 #1
8 8478
NeoPa
32,568 Recognized Expert Moderator MVP
Are we talking about changing it whenever found?

Is this on a data entry / update form?

Is this simply about defaulting, or is the value to be determined by changes to [Haulier Invoice Number] alone.

NB. Spelling of received. This can cause problems if you're not careful.
Oct 27 '08 #2
missinglinq
3,532 Recognized Expert Specialist
Assuming that this is a data entry form, with [POS Status] Default Value set to "Awaiting" this code will set it according to your specs:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Hauler_Invoice_Number_AfterUpdate()
  2.  If IsNull(Me.Hauler_Invoice_Number) Then
  3.    Me.POD_Status = "Awaiting"
  4.  Else
  5.    Me.POD_Status = "Received"
  6.  End If
  7.  End Sub
Welcome to Bytes!

Linq ;0)>
Oct 27 '08 #3
P00HB33R
6 New Member
Thanx 4 the reply.

It is a data entry form. With a bunch of fields, but the fields concerned are [Haulier Invoice] and [POD] status. The [POD Status] field is set to "Awaiting" as default because the [Haulier Invoice] is empty on entering data and for a few days afterwards. But as soon as a value is entered into [Haulier Invoice] I need the [POD status] to change to "Recieved". Thanx for ur help so far. Where should I enter that code?

Thanx.
Oct 28 '08 #4
NeoPa
32,568 Recognized Expert Moderator MVP
Linq's logic will work for you then. You will need to be careful as you seem to write the field names differently every time - even when you're trying to explain their exact names.

You can take take the code and change it to match the actual names in your project. This code would be put in the form's own module.

Remember, "Received" is spelled as I have, and not with the i before the e (as I brought to your attention previously). Attention to detail is a fundamental requirement for working with databases. Ignore it at your peril.
Oct 28 '08 #5
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. A further observation is that if the only circumstances in which [POD Status] takes the value Received is when there is an invoice number recorded there is no need to store the value as a discrete field. In such circumstances you could use a query in which you include a calculated field to indicate the POD Status. The calculated field can either use an In-line IF (IIF) statement to test the invoice number field for null, or a custom function based on Linq's example to do so.

The advantage of using a calculated field is that it is calculated automatically on entry or clearance of the invoice number. This does away with the need to use the After Update event to set the field contents altogether, and it prevents anomalies that could arise from the status field not accurately reflecting the real status of the record concerned. This can arise if, for example, a user records an invoice number against the wrong record, then subsequently corrects the record by removal of the value from the invoice number field. Doing this will leave the discrete status field still at its Received setting unless it too is changed manually. This possibility for error does not arise if a calculated field is used instead.

-Stewart
Oct 28 '08 #6
P00HB33R
6 New Member
Guys got it working. Ended up using the following code: IIF([Haulier Invoice No]="","Awaiting", "Recieved") . It did the job perfectly. Thanx to all of you who helped me, and thanx for all the spelling tips ;-).

Cheers 4 now
Oct 29 '08 #7
NeoPa
32,568 Recognized Expert Moderator MVP
Pooh,

Pleased you got it working, but don't think the spelling tips were about me being anally retentive (I am, but that's not the point). They are about creating problems for yourself later on down the line.

Consider a name like [a6705gh]. Not easily recognisable, therefore always spelled as seen. A word that is recognised, on the other hand, is likely to be entered wrongly (by a user or by a developer working on your project sometime in the future). If they recognise the word, they will assume it is spelled in the normal way and you then have problems.

This is your choice of course, but it would be remiss of me not to point out this obvious problem in your coding if I see it.
Oct 29 '08 #8
P00HB33R
6 New Member
Pooh,

Pleased you got it working, but don't think the spelling tips were about me being anally retentive (I am, but that's not the point). They are about creating problems for yourself later on down the line.

Consider a name like [a6705gh]. Not easily recognisable, therefore always spelled as seen. A word that is recognised, on the other hand, is likely to be entered wrongly (by a user or by a developer working on your project sometime in the future). If they recognise the word, they will assume it is spelled in the normal way and you then have problems.

This is your choice of course, but it would be remiss of me not to point out this obvious problem in your coding if I see it.
Thanx man, I truly understand ur point. Will implement it in the future.
Oct 29 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
11037
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic SFSB and, from there, to the database. On the front end, all cells appear as text fields. However, for certain cells, when the user clicks on the cell, the text field turns into a drop-down field (i.e. Select object), defaulting to the value...
2
2247
by: JC Mugs | last post by:
I have a form that when you tab from field to field that the entry point is blank, but if you point and click in the field it brings up a 0 and data entry is started to the left of the zero. Thus if you are click and enter 8 becomes 80, but if you tab to the field and enter 8 it is 8. So my question: is there an easy way to have Access XP-2002 keep the entry on the form blank when you click on a field to enter data?
1
1702
by: Manton | last post by:
Hi. I'd like to know if after the records have been ticked , whether one can then have those same records unticked - in case a mistake had been made the first time to tick them. ---------------------- >Assuming your table has a numeric primary key named "ID", you can get 170 >random records in the date range with this kind of thing: SELECT TOP 170 * FROM WHERE Between #1/31/2004# And #2/29/2004#
6
4811
by: Sami | last post by:
Problem: Social Security number being used in a database. First problem is that it will not permit numbers beginning in zero to be entered - it sees it as a null or empty space from what I can tell. Next, foreign students have & as the initial part of their SSN. How to do this?? Finally, how do I force the cursor to the far left of the field so the
2
3030
by: Kevin Myers | last post by:
Hello, Have yet another problem on a form that has me stumped. In a table that I am working with, the values for one of the fields are stored in meters. However the values that are supplied for data entry are in feet. Therefore, I don't believe that I can use a bound text box to support the entry of data for this field. I could use an expression to compute the value for display in the text box as follows: *100/(12*2.54)
2
2285
by: Megan | last post by:
Hi everybody- I have 2 tables, Hearings and Rulings. Both have primary keys called, CaseID, that are autonumbers. I don't want both tables to have the same autonumber. For example, if Hearings has 55, then I want Rulings to have a number greater than 55. Two or more Hearings may be entered before a Ruling is entered. For example, Hearings with CaseIDs= 55, 56, and 57 may be entered before a Ruling or vice versa. There is no definite...
2
2079
by: AA Arens | last post by:
Somebody willing to assist me in the following? I want to have values from one field copied to another field when I choose choose a item from a drop down menu. I have 2 forms: 1 Company contact info 2 Employee contact info When I finished form 1, I jump to form 2.
9
3109
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to be inserted into a standard web address in the table (the filed name is link) in ddw1 Example address ---
8
3258
by: ivijayan | last post by:
HI. I have the following query:- How do i create field which updates its contents on the basis of data in another field in same record. especially if I have a Date field, how can I change the contents of Status field in the same record based on the date field. for ex:- - If the date is maximum the content in status should be "Current" - If there are 2 records for one ID and if the date field content is minimum the content in status...
0
8857
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...
0
8633
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
7367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
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
5654
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
4180
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
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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
1993
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.