StuckfromPR
Registered User.
- Local time
- Today, 13:20
- Joined
- Sep 15, 2008
- Messages
- 18
I need help urgently on executing a query which calculates a percentage (when a button is clicked in a form) , and I need the value of that percentage to be posted in the same form. This is the code that I have so far, please help me out since I am STUCK.
Private Sub Sub_Btn_Click()
Dim db As Connection
Dim rs As Recordset
Dim strId As String
Dim strMonth As String
Dim strWeek As String
Dim strSQL As String
Set db = CurrentProject.Connection
Set rs = adodb.Recordset
txtValue.Value = "" 'This is where I need the value to go into.
strId = EID_drp.Value
strMonth = Month_drp.Value
strWeek = Week_drp.Value
strSQL = "SELECT Sum([Table1].[Hours])/40*100 AS txtValue " & _
"FROM [Table1] INNER JOIN [Table2] ON [Table1].[ChargeDate] = [Table2].[CalendarDay] " & _
"WHERE Table1.EmpIdNbr= '" & strId & "' AND Table2.CalendarWeek= '" & strWeek & "'" & _
" AND Table2.CalendarMonth= '" & strMonth & "' AND ((Table1.Charge) Like '7%';"
rs.OpenRecordset (strSQL)
End Sub
This is not working for me, please HELP!!!!!!
Thanks!
Private Sub Sub_Btn_Click()
Dim db As Connection
Dim rs As Recordset
Dim strId As String
Dim strMonth As String
Dim strWeek As String
Dim strSQL As String
Set db = CurrentProject.Connection
Set rs = adodb.Recordset
txtValue.Value = "" 'This is where I need the value to go into.
strId = EID_drp.Value
strMonth = Month_drp.Value
strWeek = Week_drp.Value
strSQL = "SELECT Sum([Table1].[Hours])/40*100 AS txtValue " & _
"FROM [Table1] INNER JOIN [Table2] ON [Table1].[ChargeDate] = [Table2].[CalendarDay] " & _
"WHERE Table1.EmpIdNbr= '" & strId & "' AND Table2.CalendarWeek= '" & strWeek & "'" & _
" AND Table2.CalendarMonth= '" & strMonth & "' AND ((Table1.Charge) Like '7%';"
rs.OpenRecordset (strSQL)
End Sub
This is not working for me, please HELP!!!!!!
Thanks!
Last edited: