473,499 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

If then Else or something similar

3 New Member
Hi Everyone,
I am in a bit of a pickle and need some expert advice. I have a db in access. I am trying to create a query with fields from the tables. In my query I need to take the value of one field and depending on what the value is pull a date from other fields. I have tried a IIF and it errors. Tried to write an if-then-else function ( which I doubt I did right since I have never done one) and I get an undefined expression error.

So for my example it would be from the function I wrote....

Public Function StatusDate(StatusDate)
If [WO Info Main]![WO Status] = 1 Then
StatusDate = [WO Info Main]![Final Date Received for Estimate]
Else
If [WO Info Main]![WO Status] = 2 Then
StatusDate = [WO Info Main]![Date Estimate Completed]
Else
If [WO Info Main]![WO Status] = 3 Then
StatusDate = [WO Info Main]![FD Assign Date]
Else
If [WO Info Main]![WO Status] = 4 Then
StatusDate = [WO Info Main]![FD Approval Sent Date]
Else
If [WO Info Main]![WO Status] = 5 Then
StatusDate = [WO Info Main]![Development Assign Date]
Else
If [WO Info Main]![WO Status] = 6 Then
StatusDate = [WO Info Main]![Test Deploy Date]
Else
If [WO Info Main]![WO Status] = 7 Then
StatusDate = [WO Info Main]![Production Deploy Date]
End If
End If
End If
End If
End If
End If
End If
End Function

Can someone tell me if this is something I can do or if there is another way. Any help would be much appreciated and any ribbing as well. Thanks.
Apr 10 '08 #1
4 2471
FishVal
2,653 Recognized Expert Specialist
Hi, there.

I think SELECT CASE construction or, even better, table lookup or, even more better, database normalization would look more elegant.

Regards,
Fish
Apr 10 '08 #2
lutzkac
3 New Member
And how would I create a select case. Like I said I am pretty novice to this and not even sure if I wrote this function right. Thanks for the help.
Apr 10 '08 #3
FishVal
2,653 Recognized Expert Specialist
Have you already tried to find it in Access help?

Kind regards,
Fish.
Apr 10 '08 #4
lutzkac
3 New Member
Yes I have used the very limited Help feature on Access, I have search on countless forum pages for examples to go by. The problem I have is none of the example I have found are doing exactly what I am looking for which is evaluating one field and based on that field populate with another field. So I have searched hi and low as well as experimented and no luck.
Apr 10 '08 #5

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

Similar topics

39
6007
by: Erlend Fuglum | last post by:
Hi everyone, I'm having some trouble sorting lists. I suspect this might have something to do with locale settings and/or character encoding/unicode. Consider the following example, text...
11
3738
by: hasadh | last post by:
Hi, is the assemly code for if..else and switch statements similar. I would like to know if switch also uses value comparison for each case internally or does it jump to the case directly at...
3
1736
by: Guy Penfold | last post by:
Hi all, I have an asp.net application exhibiting rather alarming behaviour. Among other things, the application provides actors with an online profile that allows them to showcase their skills,...
24
8563
by: Kunal | last post by:
Hello, I need help in removing if ..else conditions inside for loops. I have used the following method but I am not sure whether it has actually helped. Below is an example to illustrate what I...
1
1440
by: Tim | last post by:
I am fairly new to VS 2005 and I have a unique situation that I would like ask the group. I have some sensitive files and documents that I want to deloy to authorized usres. In a nutshell, I want...
12
1223
by: why? | last post by:
I've been having problem with the following code. It's supposed to print the prime numbers between 10 and 100. But i'm not getting any output, i.e. i guess the outer 'for' loop is being traversed...
9
1583
by: RP | last post by:
I have following code lines: =============================== if (txtMethod.Text != "D") || (txtMethod.Text != "F")) { txtMethod.Clear(); txtMethod.Focus(); } else {
18
1426
by: miller.paul.w | last post by:
Ruby has a neat little convenience when writing loops where you don't care about the loop index: you just do n.times do { ... some code ... } where n is an integer representing how many times you...
23
2753
by: bearophileHUGS | last post by:
So far in Python I've almost hated the 'else' of the 'for' loops: - I have problems to remember its meaning; - It gives me little problems when I later want to translate Python code to other...
0
7128
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
7169
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
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7385
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...
0
5467
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,...
0
3096
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...
0
1425
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 ...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.