blank records only if new day otherwise show old records!

there is no time element in my date field, but I can put one right? using now () ??

I can put the shift start field in the tblEmployees as well, but as for now I don't have the field :s
 
Well, I don't see how you can enforce a time part without having it in your table. And adding a time element now won't be a good idea because old records don't have that part to it.

And you don't have a Start Field too so there's nothing to referencing.
 
oh well! thanks for your great help :) this was more than enough. I was just trying to be absolutely perfect lol
 
It could have been if your tables were absolutely perfect :)
 
just one more thing!! is it necessary to put the code in the onclick event of form which opens this form?

can I put the code in the onload event of the mainform?
 
Whichever code opens the form is where you put the code.
 
got it! but here is the thing.

i have three subforms under the main form. each subform comes from a different table. I tried using 3 if statements but that doesn't work!! If I just use it once, it works for the subform I mention... how would I incorporate all 3?

thanks again :)
 
But they all have EmployeeID and/or ActivityID field(s)?
 
So why not just repeat some of the steps but change the subform control name?
 
Private Sub cmdgo2_Click()


Dim userID As Long
Dim strQuery As String
userID = DLookup("EmployeeID", "qryEmployeeNames", "EmployeeName='" & Me.txtwinusername & "'")



If DCount("*", "tblactivities", "EmployeeID = " & userID & " AND dte = Date()") = 0 Then
DoCmd.OpenForm "entertodaysrecords", acNormal, , "EmployeeID = " & userID
Forms!entertodaysrecords!ctrActivity.SetFocus
DoCmd.RunCommand acCmdRecordsGoToNew

Else
DoCmd.OpenForm "entertodaysrecords", acNormal, , "EmployeeID = " & userID

With Forms!entertodaysrecords!ctrActivity
.SetFocus
.Form.Recordset.FindFirst "ActivitiesID = " & DMax("ActivitiesID", "tblactivities", "EmployeeID = " & userID)
End With
End If

If DCount("*", "tblafternoon", "EmployeeID = " & userID & " AND dte = Date()") = 0 Then
DoCmd.OpenForm "entertodaysrecords", acNormal, , "EmployeeID = " & userID
Forms!entertodaysrecords!frmctrActivity2.SetFocus
DoCmd.RunCommand acCmdRecordsGoToNew
Else
DoCmd.OpenForm "entertodaysrecords", acNormal, , "EmployeeID = " & userID

With Forms!entertodaysrecords!frmctrActivity2
.SetFocus
.Form.Recordset.FindFirst "ActivitiesID = " & DMax("ActivitiesID", "tblafternoon", "EmployeeID = " & userID)
End With
End If


Exit_cmdGo2_Click:
Exit Sub
Err_cmdGo2_Click:
MsgBox Err.Description
Resume Exit_cmdGo2_Click

End Sub

this is the code that I am using - it works for the second subform now, but stops working for the first one
 
Here is some extra detail: subform 1 is for employees 1,2,3,4 and subform 2 is for employees 5,6,7,8 - but subform 3 (which i didnt list in the code here) is for extra reports which needs to be completed by all the employees
 
So why try to filter subform 2 if it's not for employees 1,2,3,4?
 
I want the same functionality for all the employees! they open the database, see their respective subform, get blank records if a new day otherwise they see the records they entered :s
 
My point is, if employee 2 logs in, he or she shouldn't be able to see subform 2 because it has nothing to do with them, and as a result you won't be applying that code for that employee.
 
I am using the following code in the mainform's on current event

If EmployeeID = 1 Then
Me.afternoon_slotters.Enabled = False
Me.frmctrActivity2.Enabled = False
Me.Afternoon_Slotters.Visible = False
Me.frmctrActivity2.Visible = False
Me.ctrActivity.SetFocus
End If
End Sub

where frmctractivity2 = subform2!

Now, when I click on the button that opens the mainform, it gives an error saying "focus cannot be moved to frmctrActivity2"
 
If the control is disabled at that given time, you can't set focus to it. Makes sense?
 
makes sense.

okay so I used something like this:

if userID = 1 then
*placing your code here*
end If
If userId = 2 then
*your code*
end if

it works! I assigned myself userId = 1, and I dont have to deal with the subform 2.

but for subform 3: I need all the employees. in otherwords, if a daytime employee (1,2,3,4) logs in, he will see two tabs! 1 for his own reporting and the second one is subform3.

Similarly, when night time employee (5,6,7,8) logs in, he will see two tabs!!


the code works till subforms are divided among employeeID, but how do I make it work if it is being shared like in subform 3?

sorry for the trouble :S
 
Some aircode:

Code:
If userId < 5
    hide subform 2
    execute code for subform 1
Else
    hide subform 1
    execute code for subform 2
End If
 
execute code for subform 3
 

Users who are viewing this thread

Back
Top Bottom