Im getting there, but the queries arent outputting to the listbox - any ideas please?
Code:
Option Compare Database
Private Sub TotalHoursOk_btn_Click()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim sProjectRef As String
Dim sTotalhours As String
Dim MySQL As String
Dim sGroupID As String
Dim sUserID As String
Dim sFormUser As String
sFormUser = Me.CurrentUser
sUserID = Forms!TimesheetForm!LoggedInUser.Value
sGroupID = DLookup("DepGroupID", "UserNames_tbl", "sUser='" & sUserID & "'")
If Me.ProjectRef_txtbox = "" Or IsNull(Me.ProjectRef_txtbox) Then
MsgBox "Please Enter a Project Number"
Else
If Me.TotalHours_Combo = "" Or IsNull(Me.TotalHours_Combo) Then
MsgBox "Please Select from the drop down list"
End If
Select Case Me.TotalHours_Combo
Case "All Employees"
If sGroupID = "2" Then
Me.Totalhrs_listbox.RowSource = ("Select * from qryTotalHrsALL")
'*******************
'DoCmd.OpenQuery "qryTotalHrsAll"
'MySQL = "Select * From TimesheetTable WHERE [ProjectRef] LIKE '*" & Me.ProjectRef_txtbox & "*'"
' QDef (MySQL)
'Call TotalHours("qryTotalHrsAll", MySQL)
'Totalhrs_listbox.RowSource = MySQL
'***********************
Else
MsgBox "You are only allowed to query your own hours, change your selection to current user", vbInformation
End If
Me.TotalHours_Combo.SetFocus
Case "Current User"
Me.Totalhrs_listbox.RowSource = ("Select * from qryTotalHrsCur")
'*************************
'DoCmd.OpenQuery "qryTotalHrsCur"
'MySQL = "SELECT * FROM TimesheetTable WHERE ProjectRef LIKE '*" & Me.ProjectRef_txtbox & "*'AND " & sFormUser & ""
'QDef (MySQL)
'Call TotalHours("qryTotalHrsCur", MySQL)
'*************************
End Select
End If
End Sub