Link to home
Create AccountLog in
Avatar of DiegoRa
DiegoRaFlag for United States of America

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Hah - looks like we're all giving the same advice.
Avatar of DiegoRa

ASKER

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")));
>>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
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"
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.
Avatar of DiegoRa

ASKER

it was the query:
i changed it to
Between [Forms]![PunchAdministration]![ComboGoBack] And DateAdd("d",7-Weekday(Date()),Date()))); 

Open in new window

Avatar of DiegoRa

ASKER

The only problem now is that my data isn't showing now
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.
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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.