I changed it completely and now i have problem " data type mismatch in criteria expression " at 
Set rest = mydb.OpenRecordset(temp, dbOpenDynaset)
code
Private Sub Command2_Click()
Dim mydb As DAO.Database
Dim rest As Recordset
Dim temp As String
Dim mpayroll As String
Dim mpage As String
Dim...