473,395 Members | 1,689 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.

How to use a control source and add an expression?

I am building a data base for training, I want to be able to have a control source on a field in a form along with an expression for the field,The expression im using is "DateAdd("interval",Number,[Field]). I want to be able to type in a issue date in one field and have it automatically add the expiry to the other field as well as the query and table.
Jan 10 '14 #1
10 2657
NeoPa
32,556 Expert Mod 16PB
Set the .DefaultValue to the formula you want. You can also set it again in an AfterUpdate event procedure of the first control.
Jan 10 '14 #2
The Data Entered in the Issue Field still does not calculate onto the Expiry field after changing the DefaultValue, and adding to AfterUpdate
Jan 10 '14 #3
zmbd
5,501 Expert Mod 4TB
rudycortez2:
Is there some reason you need to store the expry date?
One can use a calculated field in a query (or an unbound control) to, well, calculate the date upon demand.
Jan 10 '14 #4
Yes. I'm building a training data base that have classes from OSHA. The issue date and expiry date are very important. I have all the trainings in the same query and table. But have different forms for each. I also have a main training form that has all the trainings. What my end goal is to be able to just enter in the issue date and it will automatically enter the expiry date. And then I would like to build different queries for each training to filter out expired trainings.
Jan 11 '14 #5
NeoPa
32,556 Expert Mod 16PB
Frustratingly, you don't seem to deal with the points raised.

My suggestion from post #2 would work. If you have a problem implementing that let us know what that problem is. Currently I cannot help you as you don't say what the problem is.

As for the question as to why you need an Expiry date, you answer that, but not in a way that answers the question. You only explain why an Expiry date is important. Not why it needs to be stored.
Jan 11 '14 #6
zmbd
5,501 Expert Mod 4TB
rudycortez2
I understand what you are doing, OSHA requirements are something I deal with every day.

Lets say for example we are interested in Mr. Zulu's missing training, then we could use WHERE clause to return all passed dates that are a year or more older that todays date (or null/zls), just subtract one year from current date (or include a null check), this returns everything that is out of date and so forth.

If you want to see the retraining dates then a calculated field that adds a year to the passed date.

In neither case do I save these results, they are calculated on demand via the query.

This is one of the times that I would store the training date for audit reasons for every class taken and passed; however, that's database design.
Jan 11 '14 #7
NeoPa:

Thats exactly it, when i entered the expressions, into the fields .DefaultValue, but it does not do the calculations. Nor does it store the information onto the Table or Query.

And it needs to be stored so i can run a query on it to search out of date training, and for my better half the Human Resources Director can understand how to use it, im simply a Safety Director with little experience with Access.

zmbd:

Yes i do not understand how to do the "Where". Someone else was working on this Database before me but quit, he was our tech guy. So im having difficulty figuring out expressions and how exactly to do all this.

So what i have tried so far is putting the expression into the control source, and the calculations did work, but did not store it to the table or query.

My next try was what Mr NeoPa recommended and the calculations did not work, it would only store what was manually typed it.
Jan 11 '14 #8
zmbd
5,501 Expert Mod 4TB
ok,
I'm going to PM you my set of standard tutorials. In the long run these will greatly help you as you progress.

As for the query design, this diverges enough from the current thread that I think we'll need to split this thread into a new one.

This would be an example - there are many more
Expand|Select|Wrap|Line Numbers
  1. SELECT tbl_data.data_pk
  2.    , tbl_data.data_text
  3.    , tbl_data.data_timestart
  4. FROM tbl_data
  5. WHERE (
  6.    ((tbl_data.data_timestart)
  7.       >=DateAdd("y",1,Date())));
In the Query editor I dragged the fields:
data_pk/text/timestart into the grid
Below the data_timestart in the first criteria row I entered the calculation <=DateAdd("y",-1,Date()) (actually I would more than likely limit this further as every record with the date one year or more less than current will return ... 1908-2013)
But this will give you an idea...

I've a Christmas Party to get ready for, I'll send you the PM here this evening (my time (-_^) )once you work thru those tutorials you'll have the tools to handle this!
Also look for this thread to split at that point, I'll send the link.
Jan 11 '14 #9
NeoPa
32,556 Expert Mod 16PB
RudyCortez2
"Thats exactly it, when i entered the expressions, into the fields .DefaultValue, but it does not do the calculations. Nor does it store the information onto the Table or Query."
That's not an explanation of your problem or the difficulties you encountered trying to get it to work. You don't include any code showing what you tried. You don't explain what was wrong with it other than stating it didn't work.

RudyCortez2
"And it needs to be stored so i can run a query on it to search out of date training"
That simply isn't true. Queries can be run that produce such a value using a formula. That is why I asked you the question. Because I knew that the answer was almost certainly that you have no reason to suppose it needs to be stored at all, and having to consider the question would make you realise you're on the wrong track with all this. Ignoring the question the first time simply meant that you didn't get the benefit I anticipated for you. It's never a good idea to ignore questions or suggestions from anyone you request help from. There's always a chance they may know what they're talking about and you'll miss something you need.

My advice would still be to avoid saving it anyway, but if you're still more comfortable with that approach in spite of all the advice given, then we still can help you, but you'll need to be a bit more forthcoming with detailed information to avoid tying our hands.
Jan 12 '14 #10
NeoPA:

Okay, i understand where you're coming from. Okay my problem is when i use the expression DateAdd("yyyy",1[Field])in the .DefaultValue or the AfterUpdate, it does not calculate the expression.
And when you put it that way, i'm not sure what you mean by storing it?
I'm trying to make it so when i enter it into the Form, the calculated Date will show up in the Expiry Field. As well as the "Main" Form, Table,and Query that has all the training Dates and Expiry Date.
This is whats being used in the Query.
Expand|Select|Wrap|Line Numbers
  1. SELECT IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First Name]),IIf(IsNull([First Name]),[Last Name],[Last Name] & ", " & [First Name])) AS [File As], IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First Name]),IIf(IsNull([First Name]),[Last Name],[First Name] & " " & [Last Name])) AS [Contact Name], Employees.*
  2. FROM Employees
  3. ORDER BY IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First Name]),IIf(IsNull([First Name]),[Last Name],[Last Name] & ", " & [First Name])), IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First Name]),IIf(IsNull([First Name]),[Last Name],[First Name] & " " & [Last Name]));
  4.  
So im not really sure how to do any of that.
Jan 12 '14 #11

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

Similar topics

1
by: ogilby1 | last post by:
when using/writing dlookup the expression should be placed in the control source field of the properties? under what circumstances is it "put" in the beforeupdate" or "afterupdate"?
2
by: Sharon | last post by:
I've had an Access 2000 app running successfully for many months on both Windows XP and Windows 2000. Recently when my Windows 2000 users call a particular report, they get first a dialog...
6
by: Mark Lees | last post by:
I've created some fields that calculate future dates. The way they are set up they do not save to a table. This is the expression I used (=DateSerial(Year(),Month()+6,Day(). I placed it in the...
5
by: Cro | last post by:
Hello Access Developers, I'd like to know if it is possible to perform a count in an expression that defines a control source. My report is based on a query. In my report, I want a text box to...
1
by: Bill Agee | last post by:
I have a text box whose control source is set = SumPayment_qry!SumofPayment that was created by the Expression Builder. Yet when I opened the form "#Name" shows up as the result. I checked the...
2
by: Bob | last post by:
I've got a bound report with a query as the record source. I'm adding a total to the footer and have inserted a text box to display it. I'm attempting to set the control source of the text box to...
4
by: VivN | last post by:
I want to use an expression as the control source for a text box in a report (Access 2000). Whilst I have sucessfully used these simple ones =TimeToSingle(TotalHours(,))...
1
by: rinmanb70 | last post by:
For a field on a report, I'm trying to use an If/Then statement to set the Control Source depending on the day of the month. I need one Control Source for days 1-14 and another for 15-31. To do...
4
by: Anja | last post by:
Hi everyone, I am trying to use the expression builder to create input to a control in an Access report. I have a table called Records and I want to select the minimum date for a record where...
6
by: colin spalding | last post by:
Access 2003 I subform which lists financial transactions for a client in the main form, which i total in a textbox named "txtTotalPremium" in the subform footer with the Control Source "=Sum()";...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.