473,394 Members | 1,841 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,394 software developers and data experts.

date population based on more than 2 cell values

Hi.

I need help in resolving my query.

I want to update my target date based on it's raise date.
but I want to set my target date based on my task severity [i.e.Minor(15 days period), Medium(60 days period), Major(120 days period)].

So for that I have written one syntax, but it was not working.
can anyone help me out?
Expand|Select|Wrap|Line Numbers
  1. Private Sub ECR_RAISE_DATE_AfterUpdate()
  2.     If Not IsNull(Me.ECR_RAISE_DATE) Then
  3.         Me.ECR_TARGET_DATE = Me.ECR_RAISE_DATE + 15
  4.     End If
  5.     If Me.CATAGORY = "MEDIUM" Then
  6.         Me.ECR_TARGET_DATE = Me.ECR_RAISE_DATE + 60
  7.     End If
  8.     If Me.CATAGORY = "Major" Then
  9.         Me.ECR_TARGET_DATE = Me.ECR_RAISE_DATE + 120
  10.     End If
  11. End Sub
Jun 19 '17 #1

✓ answered by NeoPa

Hi Karnav.

If you would like help with a problem then it makes sense to explain what the problem is first. Saying something doesn't work without including any details is something we unfortunately see a lot of. I'm not sure why it isn't obvious to everyone but that's like a police despatcher getting an emergency call and being told there's a problem, just before the caller hangs up. It's hard to help with a problem without any clues as to what the problem is.

From what I can see the code looks workable. Category is mis-spelled, but I suspect that's also true of the Control on the form so they should match anyway. The code could be written more clearly and concisely, as I've shown below, but that doesn't mean your current code shouldn't work.

Perhaps with more in the way of what went wrong and where we could be of greater help.
Expand|Select|Wrap|Line Numbers
  1. Private Sub ECR_RAISE_DATE_AfterUpdate()
  2.     With Me
  3.         If IsNull(.ECR_RAISE_DATE) Then Exit Sub
  4.         .ECR_TARGET_DATE = DateAdd("d", Switch(.Category = "Major", 120 _
  5.                                              , .Category = "Medium", 60 _
  6.                                              , True, 15), .ECR_RAISE_DATE)
  7.     End With
  8. End Sub

2 737
PhilOfWalton
1,430 Expert 1GB
Two points.

1) Have a look at the DateAdd Function. If you think about it, ECR_RAISE_DATE is a date time field, so does ECR_RAISE_DATE + 15 mean add 15 seconds, 15 hours, 15 days, 15 years or what?

2) On the MEDIUM Category, before the End If add
Expand|Select|Wrap|Line Numbers
  1.     Exit Sub
  2.  
That way if the category is MEDIUM, you won't wast effort checking if it is MAJOR.

Phil
Jun 19 '17 #2
NeoPa
32,556 Expert Mod 16PB
Hi Karnav.

If you would like help with a problem then it makes sense to explain what the problem is first. Saying something doesn't work without including any details is something we unfortunately see a lot of. I'm not sure why it isn't obvious to everyone but that's like a police despatcher getting an emergency call and being told there's a problem, just before the caller hangs up. It's hard to help with a problem without any clues as to what the problem is.

From what I can see the code looks workable. Category is mis-spelled, but I suspect that's also true of the Control on the form so they should match anyway. The code could be written more clearly and concisely, as I've shown below, but that doesn't mean your current code shouldn't work.

Perhaps with more in the way of what went wrong and where we could be of greater help.
Expand|Select|Wrap|Line Numbers
  1. Private Sub ECR_RAISE_DATE_AfterUpdate()
  2.     With Me
  3.         If IsNull(.ECR_RAISE_DATE) Then Exit Sub
  4.         .ECR_TARGET_DATE = DateAdd("d", Switch(.Category = "Major", 120 _
  5.                                              , .Category = "Medium", 60 _
  6.                                              , True, 15), .ECR_RAISE_DATE)
  7.     End With
  8. End Sub
Jun 19 '17 #3

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

Similar topics

1
by: Scott | last post by:
In the result of a SELECT statement, how can you change cell values from NULL to BLANK? The following does NOT do it: SET fieldname = ' ' WHERE fieldname IS NULL Also, for colums with a DATE...
12
by: adrianca | last post by:
Hi All, If have a sql table with 2 columns and 2 rows with values ,]. Using t-SQL with "for xml" How can i create a xml where the cell values (not column names) appear as elements? eg:...
1
by: Richard Dixson | last post by:
Under ASP.NET (C#) I want to create a page that people can use to submit questions. This page will consist of a table with several rows of information, like: Name: Bill Smith Job title:...
2
by: Richard Dixson | last post by:
Under ASP.NET (C#) I want to create a page that people can use to submit questions. This page will consist of a table with several rows of information, like: Name: Bill Smith Job title:...
6
by: Materialised | last post by:
Hi All I have been searching the net on this for the last couple of hours to no avail. I need to fill a datagridview control based on the values entered in 2 text boxes. However I cant for...
1
by: jeganwaran | last post by:
retrieve cell values from the grid view using code
0
by: RKT | last post by:
I have a DataGridView bound to an MS Access table. This is a single- user application. When the User is adding or editing a row, the User may click on a Control elsewhere. That Control has context...
7
convexcube
by: convexcube | last post by:
To keep a record of training levels for different tasks, I have 18 option groups with 4 options values each: 0 labelled as "None", 1 labelled as "Trainee", 2 labelled as "Competent" and 3 labelled as...
1
by: silentbuddha | last post by:
Hi, I am currently having some difficulties with this sunroutine that I created. My 2 dimensional array is empty. - This code is within my UserForm1 - this sub is suppose to first select the...
3
by: Miranda Truehill | last post by:
I'm very new to programming and although I've seen a similar post that addressed this in part, I am unsure how exactly to go about this. I know I can utilize the DateAdd function but don't know...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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.