Hi all,
There is a very long story behind this but I'll just post my current problem for now...
Essentially, I'm trying to create an active employee list from a central 'employees table' table in order to run a variety of queries from it which will be date sensitive
I'm kinda new to the idea of running SQL within VBA so I'm sure that's the problem.
Anyway, here's where I get stuck with a 3075 error (full code posted... the SQL is in the last Sub):
There is a very long story behind this but I'll just post my current problem for now...
Essentially, I'm trying to create an active employee list from a central 'employees table' table in order to run a variety of queries from it which will be date sensitive
I'm kinda new to the idea of running SQL within VBA so I'm sure that's the problem.
Anyway, here's where I get stuck with a 3075 error (full code posted... the SQL is in the last Sub):
Code:
Option Compare Database
Private Sub btnDateSet_Click()
datefrom = Form_frm_DatePicker.ctrDateFrom
dateto = Form_frm_DatePicker.ctrDateTo
ErrHandler:
Select Case Err.Number
Case Is = 13
Beep
MsgBox "Invalid date(s), please try again", vbCritical, "Uh-Oh!"
Response = acDataErrContinue
Exit Sub
End Select
ActiveEmployees
End Sub
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 2279 Then
Beep
MsgBox "That's not a real date...", vbCritical, "Uh-Oh!"
Response = acDataErrContinue
Exit Sub
End If
End Sub
Private Sub ActiveEmployees()
On Error GoTo ErrorHandler
Dim strSQL As String
Dim strTable As String
strTable = "tblActiveEmp"
'Delete the table if it exists
DoCmd.DeleteObject acTable, strTable
strSQL = "SELECT * INTO tblActiveEmp FROM tbl_EmployeeDetail WHERE (((tbl_EmployeeDetail.StartDate)>=[Forms]![frm_DatePicker]![ctrDateFrom]') AND (('tbl_EmployeeDetail.[InWork?])=True));"
CurrentDb.Execute strSQL
Exit Sub
ErrorHandler:
Debug.Print Err.Number
If Err.Number = 7874 Then
Resume Next
End If
End Sub