Message Box Calculation

N

NotGood@All

I would like to create a form that ask the user what is their birthday,
calculate their age and display it on a message box. Can someone help me??

thanks
 
L

Linq Adams via AccessMonster.com

With a textbox named

txtDOB

and a command button named

cmdCalculateAge

use this code

Private Sub cmdCalculateAge_Click()
MsgBox DateDiff("yyyy", [txtDOB], Date) - IIf(Format$(Date, "mmdd") < Format
$([txtDOB], "mmdd"), 1, 0)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top