If Then Else struggle

text8 <> txtBox8

???
ken
 
Since the IIf() in the ControlSource is working why do you need to waste time with VBA?
 
I know, MoP, but I can't see why it won't work by coding ... and thought I would take advantage of the collected brains.

I've put the great IIf statement of yours into place this very moment, and it works like a dream. (A good dream, I mean.) Thank you.
 
kupe said:
I know, MoP, but I can't see why it won't work by coding ... and thought I would take advantage of the collected brains.

I've put the great IIf statement of yours into place this very moment, and it works like a dream. (A good dream, I mean.) Thank you.

Kupe - You're referring to text8 as txtbox8 in your code.

ken
 
You have the code in the wrong event.

I've fixed it here:
 

Attachments

Yes, I saw that, Ken. How crazy, sorry. However, unfortunately it still won't go. (If I can change files to include that correction, I will.)
 
It also seems the modules got mixed up. Mile probaly fixed it in what he posted. Delete all the the code in the form and do a new button with the text8 problem fixed in the code you had and it should work - it did on this side...

ken
 
Lexcerm, yes, that is the just sort of thing I had in mind. It does the job perfectly, and I'll use Mile-o-Phile's in a query - and thanks to you and MoP and Ken and philljp390 and Rich, et al, I am better educated. And happier! (It's holding onto all this knowledge that becomes the challenge.) Cheers
 
have you tried
Me.txtResult = dateadd("d",-me.txtdate1,nowdate) & " day(s)"
 
bjackson said:
have you tried
Me.txtResult = dateadd("d",-me.txtdate1,nowdate) & " day(s)"

That's pretty much what I put in my example although I used the DateDiff function since he's calculating a number of days, not adding days. ;)

Although:

Me.txtResult = DateDiff("d",Me.txtdate1,IIf(IsNull(Me.txtSecondDate), Me.txtFirstDate, Me.txtSecondDate)) & " day(s)"

That should work
 
Good to hear from you again, bjackson. No, I haven't but I will try. Thank you. And thanks, MileO-Phile. I'll add the variation to the collection.
 
From kupe's attachment near the start of the thread, it was already working fine.

For some reason he wanted to do it in code when a perfectly good expression in the ControlSource was already doing the job. :rolleyes:
 
Mile-O-Phile said:
From kupe's attachment near the start of the thread, it was already working fine.

For some reason he wanted to do it in code when a perfectly good expression in the ControlSource was already doing the job. :rolleyes:
Ours is not to reason why,
our is just to do or........................ :( ;)
 
Yes, thanks, phillipjp390, working well now. It's being questioned why I wanted to use code when I had MoP's perfectly good expression. I wanted to know how to do it in code - it seems a better approach, though I may be wrong. (Probably am.)

The expressions by MoP and bjackson are excellent, and I'll use them in the future. So much of my work for the last year has MoP's code in it. He's a genius, of course, and this is great forum of craftsmen. And both aspects are appreciated.
 
. I wanted to know how to do it in code - it seems a better approach, though I may be wrong.

The less code a module has, the better.

If a form has no module attached to it then it runs much much quicker.
 
. I wanted to know how to do it in code - it seems a better approach, though I may be wrong.

The less code a module has, the better.

If a form has no module attached to it then it runs much much quicker.
 
Thanks, MoP, for pointing that out. All noted. Cheers
 

Users who are viewing this thread

Back
Top Bottom