what is the correct method to fill the three combobox to set a birtday date?
note:
in mind... for the birthday, consider only if the customer have >= 18 year old based current date
BIRTHDAY DATE (strategy)
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
BIRTHDAY DATE (strategy)
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78487
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: BIRTHDAY DATE (strategy)
Wouldn't it be easier to let the user enter their birthdate?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78487
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: BIRTHDAY DATE (strategy)
For example:
This uses the following function:
Code: Select all
If Not IsDate(Me.txtBirthDate) Then
MsgBox "Date not valid!"
Exit Sub
End If
If Age(Me.,txtBirthDate) < 18 Then
MsgBox "Age under 18!"
Exit Sub
End If
Code: Select all
Public Function Age(BirthDate) As Long
Dim y As Long
Dim m As Long
Dim d As Long
m = DateDiff("m", BirthDate, Date)
d = DateDiff("d", DateAdd("m", m, BirthDate), Date)
If d < 0 Then
m = m - 1
End If
Age = m \ 12
End Function
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: BIRTHDAY DATE (strategy)
HUMMM..HansV wrote: ↑06 May 2021, 14:36For example:
This uses the following function:Code: Select all
If Not IsDate(Me.txtBirthDate) Then MsgBox "Date not valid!" Exit Sub End If If Age(Me.,txtBirthDate) < 18 Then MsgBox "Age under 18!" Exit Sub End If
Code: Select all
Public Function Age(BirthDate) As Long Dim y As Long Dim m As Long Dim d As Long m = DateDiff("m", BirthDate, Date) d = DateDiff("d", DateAdd("m", m, BirthDate), Date) If d < 0 Then m = m - 1 End If Age = m \ 12 End Function
Now with your suggetion, i use textbox.
possible to insert in text box this format string: __/__/____
-
- Administrator
- Posts: 78487
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: BIRTHDAY DATE (strategy)
You might use the Masked Edit Control with the Mask property set to ##/##/####
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36