HELP!!

I'm trying to build a TimeClock Database where it stores the employee's working hours.
Right Now I'm working on a form for the administrator where he can look up the employees date of work, time in, time out and total time which is all stored in a table called Punches.

In my form header i have an unbound comobox with the Row Source:SELECT mwsecMY.Code, mwsecMY.Name FROM mwsecMY ORDER BY mwsecMY.Name;......This is just the Employee's Names that come form a table called mwsecMy from a different database i imported.
The combobox has the following code on the AfterUpdate Event:
Private Sub MyEmployeeFilter_AfterUpdate()
On Error GoTo MyErrorControl

    Me.Filter = "[Code]='" & Me.MyEmployeeFilter & "'"
    Me.FilterOn = True
    
Exit Sub
    
MyErrorControl:
    Select Case Err.Number
    Case 0
        Resume Next
    Case Else
        MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "MyEmployeeFilter_AfterUpdate ERROR"
        Resume Next
    End Select
End Sub

Open in new window


The form's Record Source is : SELECT Punches.DateOfWork AS MyDateOfWork, Punches.TimeIn AS MyTimeIn, Punches.TimeOut AS MyTimeOut, Punches.DayTotal AS MyDayTotal, Punches.* FROM Punches WHERE (((Punches.DateOfWork) Between [Forms]![PunchAdministration]![ComboGoBack] And DateAdd("d",7-Weekday("Date"),"Date")));....It's default view is : continuous forms. and the code for the form on the OnLoad Event is

Private Sub Form_Load()
On Error GoTo MyErrorControl
Dim wkStart As Date
    
    wkStart = Date - (Weekday(Date) - 1)
    Me.ComboGoBack.RowSource = wkStart & ";Current Week;" & DateAdd("ww", -1, wkStart) & ";1 week ago;" & DateAdd("ww", -2, wkStart) & ";2  weeks ago"
    
    Exit Sub
    
MyErrorControl:
    Select Case Err.Number
    Case 0
        Resume Next
    Case Else
        MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Form_Load ERROR"
        Resume Next
    End Select
End Sub

Open in new window



That right there is my problem. I put another combobox on the header and After i added that, the form stopped working. It tells me a message...This expression is typed incorrectly, or is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assinging parts of the expression to variables.

All i'm trying to do is with the second combobox on the header is to have the option to view the current week, 1 week ago, or 2 weeks ago.
DiegoRaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

peter57rCommented:
I just created a blank form and added a combo box called combogoback
When I copied and pasted in your form load code it worked fine.
So whatever the problem is it is not directly an issue with that code.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andrew_WebsterCommented:
I'm not seeing a problem here either.

So, my immediate instinct would be"
1. Take a back-up
2. Decompile (open the file using the command line: "c:\Path to msaccess.exe" "d:\Path to your\file.mdb" /decompile) - adjust the paths to your circumstances
3. Recompile (ALT+F11 to open VBA editor, Debug, Compile)
4. Compact and Repair (not in front of 2007, but it's in there somewhere!)

If that all fails, then create a new file, and import all your object to it and try again.
p912sCommented:
Could be the form itself. And the problem can survive Compact and Repair.

1. Create a new form
2. Create (DO NOT copy from old form) the objects on the form.
3. You can copy/paste the code from your old form to the new one.
3. Delete the old form
4. Rename the new form.
5. Compact and Repair again.
6. Give it a try.

I've seen this work on many occasions...

Hope that helps.

Scot
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Andrew_WebsterCommented:
Hah - looks like we're all giving the same advice.
DiegoRaAuthor Commented:
Do you think is the query then?
In the criteria row of the Date field in my query i put:

 Between [Forms]![PunchAdministration]![ComboGoBack] And DateAdd("d",7-Weekday("Date"),"Date")));
p912sCommented:
>>Hah - looks like we're all giving the same advice.
Except for the import the objects... I've seen that carry the problem, but creating new objects doesn't. It's a mystery that has been around since Access '97 that I'm aware of.

>>Between [Forms]![PunchAdministration]![ComboGoBack] And DateAdd("d",7-Weekday("Date"),"Date")));
I didn't notice the FIELD named Date, I would change that to MyDate or something...

Scot
peter57rCommented:
Agree with Scot    and  "date" is a text value, not a field value; Best to change the name but if you can't do that then use [Date] not "Date"
Andrew_WebsterCommented:
Agreed all round.

If you're stuck with "Date" being a field name, then it might be worthwhile investing in Rick Fisher's Find and Replace to change it, and Helen Feddema's LNC Rename to avoid the issue in the first place.  It'll set you back the cost of a couple of movie tickets and you'll use it every day you're developing in Access.
DiegoRaAuthor Commented:
it was the query:
i changed it to
Between [Forms]![PunchAdministration]![ComboGoBack] And DateAdd("d",7-Weekday(Date()),Date()))); 

Open in new window

DiegoRaAuthor Commented:
The only problem now is that my data isn't showing now
Andrew_WebsterCommented:
Sounds like you've got to do some debugging.

Create a query in the query designer that does what you want using literal values typed in for the parameters.  Then use the expression builder to replace them with the reference to the control, and to build the date.  

You're close, you just have to tweak it.  Easier for you than for us, so keep going.
nungaCommented:
Check this part of your criteria:

DateAdd("d",7-Weekday(Date()),Date())

This is adding a different number of days based on the day of the week that the form is being viewed.

If you view the form on a Monday, your criteria will return records from [ComboGoBack] + 5 days.

If you view the form on a Saturday, your criteria will return records from [ComboGoBack] + 0 days.
TracyVBA DeveloperCommented:
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.