Logic help

RexesOperator

Registered User.
Local time
, 22:20
Joined
Jul 15, 2006
Messages
604
I realize looking for help on logic on New Year's Eve may be asking too much, but I will give it a whirl.

I know I could solve this problem with an update query, but for the moment I would like to avoid that. I should be able to do this programmatically.

I have a field that contains one of five letters: d,e,f,g,m. I have the query set up with a parameter that is filled from a form: Forms!frmGETQFLAG!txtOLDQFLAG. The problem is that d and f mean the same things and e and g mean the same thing. So I would like the parameter to be smart enough to know that it should provide f when d is selected and vice versa.

I have tried variations on IIf, but I can't seem to get the query to display both of d AND f or both of e AND g.

This is not essential. Everything else is complete (the db will be deployed on Tuesday). But this would be a nice to have feature.
 
I figured out a kludge. I have an invisible text box that gets its value from an if statement in VBA (if txtOLDQFLAG = "f" then txtOLDQFLAG2 = "g"). The query then gets it's values from either txtOLDQFLAG Or txtOLDFLAG2. Not elegant, but it means I don't have to change any of the original data from the old database AND I get what I want.

Thanks for all your time and effort with the many questions (> 500 posts? Wow!) people have answered for me.
 
Last edited:
RO,

Another possible work-around is to use a Public Function to
provide the value for you.

Base your form on a query and add a new column:

NewFlag: GetFlag([OldFlag])

Then just use the NewFlag column as if it were from the
original table itself.

Add this in a Public Module:

Code:
Public Function GetFlag(strOldFlag As String) As String
Select Case strOldFlag
   Case "d"
      GetFlag = "f"
   Case "e"
      GetFlag = "g"
   Case Else
      GetFlag = ""
   End Select
End Function

Happy New Year,
Wayne
 
Happy New Year to you too. I guess the New Year's parade is over! Shouldn't you be watching the Rose Bowl?

Certainly more elegant - and it works (I just tried it). However I have left things as they are. Instead I will get permission to change the original data, then I can continue to use my simple unbound form to feed the parameter query. Once the data is changed all I need to do is delete two lines of code and a textbox.
 

Users who are viewing this thread

Back
Top Bottom