Macro If - Else statement Not Working (1 Viewer)

Gasman

Enthusiastic Amateur
Local time
Today, 17:27
Joined
Sep 21, 2011
Messages
14,323
@ gasman..Can you explain y does the statement sends email when we just put numeric in if statement..

If the statement is true then the code will be executed.?

You said that your control for some strange reason was text, so I suggested using "8", only to see what it contained instead of getting the type mismatch error.

If for some strange reason it is a string, then using Val as arnelgp suggested would allow you to compare as numeric.

Personally I'd be investigating why it is not numeric, but then again, I'd be using VBA to do this. :)
 

santhosh23

Registered User.
Local time
Today, 09:27
Joined
Jul 21, 2015
Messages
74
@Gasman ..thanks for the explanation and your time..I will work on that
 

santhosh23

Registered User.
Local time
Today, 09:27
Joined
Jul 21, 2015
Messages
74
@arnelgp..I have mailed you my db file
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:27
Joined
May 7, 2009
Messages
19,248
I hope this is what you want to accomplish.
First I created a data macro on RecordTable
Then I call that macro inside "Email to Manager Ver2" macro.
Please study the codes.
 

Attachments

  • MasterAccess.accdb
    2 MB · Views: 124

santhosh23

Registered User.
Local time
Today, 09:27
Joined
Jul 21, 2015
Messages
74
@arnelgp..thank you for the help ..yeah this is what i tried..but can you tell me how you created the macro RecordTable.TestForEightHrsOrMore and where can i find the codes for that. I think the worktime is modified from 00:00:06 AM to 12:00:06 AM , in that case every macro will just execute the if statement rite..becoz every value is greater than 8..??
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:27
Joined
May 7, 2009
Messages
19,248
if its 8 hrs or more the macro will run.

you can view the macro code when you open RecordTable in design view. On the ribbon Create Data Macros->Create/Edit Named Macros.
 

santhosh23

Registered User.
Local time
Today, 09:27
Joined
Jul 21, 2015
Messages
74
@arnelgp..hey i just saw code and it was working fine , i used a query yest to find the same and it worked but using if-else is more simple i guess..thanks for helping
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:27
Joined
May 7, 2009
Messages
19,248
there are always better alternative approach, you just have to search more.
 

Users who are viewing this thread

Top Bottom