Unbound Form w/ Bound Listbox

burrina

Registered User.
Local time
Today, 06:57
Joined
May 10, 2014
Messages
972
My code is not working.
1. The code below should equal the Current Month
2. It does not close the form if no data.


PHP:
If DLookup("[CurMonth]", "tblEmpEvaluation") = Format(DateSerial(Year(Date), Month(Date), Day(Date)), "mmmm ")
  DoCmd.OpenForm "frmEvalNotice"
End If

PHP:
If DLookup("[CurMonth]", "tblEmpEvaluation") <> Format(DateSerial(Year(Date), Month(Date), Day(Date)), "mmmm ") Then 'No Data. NotWorking?
    DoCmd.Close acForm, "frmEvalNotice"
End If
 
Is this code being run in the Open event of frmEvalNotice or from another form?

By the way, you can use one of the following to return the current month your desired format:
Code:
format(date(), "mmmm")

monthname(month(date()))
 
One form is the Main Form which opens the other form if criteria is met.
frmMainMenu is the Main form
frmEvalNotice is the popup form with a listbox on it.

The idea is to check and see if it is the current month and if so, open frmEvalNotice.
Since other append code tuns before this code, it populates the table.


1st Code is the for the Main form.
2nd Code is for the popup form with the listbox.
 
It seems unusual to use DLookup() with no criteria. What record will it return, who knows?
 
The month is set at table level. CurMonth =Format(Now(),"mmmm")

db opens, main form loads, tblEmpEvaluation gets populated
If CurMonth is in that table then a popup form opens with a list of employees who need to be evaluated.

PHP:
If DLookup("[CurMonth]", "tblEmpEvaluation") = Format(Now(), "mmmm") Then 
    DoCmd.OpenForm "frmEvalNotice"
End If


This seems to resolve my issue. I must be Date Challenged ?
 
Last edited:
So will there only ever going to be one record in the table? You remember that DLookup() only returns one "random" value without criteria?

And I suppose, going back to your first post, you don't need to close the form if it never opens.
 
If Criteria is not met form does not open, so that is resolved. One thing solved the other. Yes, multiple records.

Thanks,

Have a Good Day !
 

Attachments

  • EmpEval.jpg
    EmpEval.jpg
    68.6 KB · Views: 104
You've got some celebrities on your database, good on you! ;)
 

Users who are viewing this thread

Back
Top Bottom