?
Solved

Month in combo box vs system date

Posted on 2011-10-14
10
Medium Priority
?
303 Views
Last Modified: 2012-06-27
Experts,
On my form I have a combo box cboMonthID. I need to check that the month selected must be less than today's date.

Here's my table tblMonth
MonthID (PK)
Month (text)
0
Comment
Question by:Frank Freese
  • 6
  • 3
10 Comments
 
LVL 75
ID: 36969834

This assumes MonthID is the Month Number ?

Private Sub cboMonthID_BeforeUpdate(Cancel As Integer)

If Me.cboMonthID >= Month(Date()) Then
    MsgBox "No Can Do!"
    Cancel = True
End If

End Sub
0
 
LVL 77

Expert Comment

by:peter57r
ID: 36969835
What happens in January?
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 36969845


This assumes Month (text) is the full month name.

Private Sub cboMonthID_BeforeUpdate(Cancel As Integer)

If Me.cboMonthID.Column(1)  >= MonthName(Month(date()))
    MsgBox "No Can Do!"
    Cancel = True
End If

End Sub
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 75
ID: 36969848
Yeah ... lots of special cases ...

mx
0
 

Author Closing Comment

by:Frank Freese
ID: 36969908
thank you - that's what I needed
0
 

Author Comment

by:Frank Freese
ID: 36970020
dx,
woops - not exactly. how do I stop the user from accepting any month accept the previous month might have been a better way to have addressed my need?
0
 
LVL 75
ID: 36970076
So, you're saying there is really only one choice the user can make ... the previous month.  If so, seems like a combo box is overkill ...?

mx
0
 

Author Comment

by:Frank Freese
ID: 36970215
if not a combo box is there a better way? A list box? Don't want to use a text box.
0
 
LVL 75
ID: 36970238
Well ... there is only one choice, right ?

mx
0
 
LVL 75
ID: 36970345
generally a combo or list box is for multiple choices.  Couldn't you just have a text box that is locked and defaults to the previous Month ?
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question