Hello,
Total newby when it comes to access so im hoping someone can put me in the right direction,
I have a form which needs to be able to adjust the warrenty finish date by either 3 or 4 years from the warrenty start date depending if it has the word laptop (3 years) or desktop(4 years) in it.
This is what I have, its the best I could come up with but alas it doesnt work. Any ideas?
= IF [Model Type].AfterUpdate Like ("LAPTOP") THEN ("yyyy",3,[Warrenty Start] ) ELSE ("yyyy",4,[Warrenty Start])
8 1804 PEB 1,418
Expert 1GB
The structure that you want to use is:
IIF(Condition, true value, False value)
= IIF ([Model Type]="LAPTOP" ,datepart("yyyy",Warrenty Start] ) ,Datepart("yyyy",[Warrenty Start]))
:)
NeoPa 32,556
Expert Mod 16PB
The following code should work for you.
It's basically what PEB said but with a few minor amendments. - =DateAdd("yyyy", IIf(UCase([Model Type])="LAPTOP", 4, 5), [Warranty Start])
NB. I respelt Warranty - this may not match what's in your db.
I used UCase() in case values in [Model Type] are entered by humans (dodgy lot they are).
I strongly recommend not to use names with embedded spaces. Your choice, but they are likely to cause you more problems in the long run.
The following code should work for you.
It's basically what PEB said but with a few minor amendments. - =DateAdd("yyyy", IIf(UCase([Model Type])="LAPTOP", 4, 5), [Warranty Start])
NB. I respelt Warranty - this may not match what's in your db.
I used UCase() in case values in [Model Type] are entered by humans (dodgy lot they are).
I strongly recommend not to use names with embedded spaces. Your choice, but they are likely to cause you more problems in the long run.
----
tried both and no luck
the word laptop in the search is only part of the text e.g IBM x31 laptop, would that make a difference
In that case, just tweak the IIF statement provided earlier by Peb and NeoPa, whichever one u used
e.g.
[Model Type] LIKE "*LAPTOP*"
NeoPa 32,556
Expert Mod 16PB
Not forgetting the UCase() and the spelling of the field name.
I spelt it to match the word rather than your posted field name so if you tried the code by simply copying and pasting, then it certainly wouldn't have worked.
pks00's is the correct way to formulate the <condition> within the IIf() function though.
Not forgetting the UCase() and the spelling of the field name.
I spelt it to match the word rather than your posted field name so if you tried the code by simply copying and pasting, then it certainly wouldn't have worked.
pks00's is the correct way to formulate the <condition> within the IIf() function though.
Yes i have done that but i still dont think i understand the code,
([Model Type] LIKE "*LAPTOP*" ,datepart("yyyy",3,[Warrenty Start] ) ,Datepart("yyyy",4,[Warrenty Start]))
this is what i have inputted
cheers
NeoPa 32,556
Expert Mod 16PB
This is what you need if you want to keep your current fieldnames. - =DateAdd("yyyy", IIf(UCase([Model Type]) Like "*LAPTOP*", 4, 5), [Warrenty Start])
Cheers,
Thanks for all your input, should work a treat
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Avi Kak |
last post by:
Is there a Python function in any of the
standard-distribution modules that does
what the backticks do in Perl?
I want to run an external command and I'd
like its output to be captured directly...
|
by: Christophe |
last post by:
Greetings from Paris:
Is it possible to have two actions command within the same html form?
I have a form including an action that send the content of the form
within a very nicely formatted...
|
by: ÂÑTØÑ |
last post by:
Hi,
I was looking for a list of commands, but I can't find it.
It's about commands you can type in the Internet Explorer adress bar, to get
some information about a website.
For instance...
|
by: xtra |
last post by:
Hi Folk
I have written a module that allows you to type a bunch of commands in the
immediate window, for quick access to information when you are creating VB
code. Here it is, it may be helpful...
|
by: Ghost |
last post by:
Hello.
I have such question:
I want to create SqlCeDataAdapter object at runtime...
I'm writing:
SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter();
then I specify Select Command:...
|
by: Rich |
last post by:
Hello,
I have an oleDBDataAdapter (da1) which gets data from an
Access mdb and fills a dataset (ds1) with integer data
from "tbl1" in Access. Data displays in textboxes on a
form. The...
|
by: Tim_Mac |
last post by:
hi,
i'm new to .net 2.0, and am just starting to get to grips with the
gridview.
my page has autoEventWireUp set to true, which i gather is supposed to
figure out which handlers to invoke when...
|
by: knowthediff |
last post by:
Hello,
I have a VS 2005 windows form app that I am creating. It uses Async
socket to telnet which sends and receives commands. Everything seems
to be working fine until I attempt to process a...
|
by: AG |
last post by:
Hello,
This is my first post to this group, and on top of that I am a
beginner. So please direct me to another group if this post seems out
of place....
I have recently written a program which...
|
by: Matuag |
last post by:
Hi All,
I want to create following command buttons on a Form which users can
edit.
Save ( Save Changes made)
Cancel ( Undo data changes)
Exit ( Close form)
I am using Macros for each of...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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...
|
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...
| |