steve_rm
Mar 11th, 2004, 08:02 AM
Hello
I am using the datagrid and data environment. But my sql query does not work. Can anyone tell me what l am doing wrong from the code below.
Private Sub cmdNext_Click()
Dim strSQL As String
Dim monthName As String
'increment the months to display each month in the year
deSalaries.rscmdIncrementMonths.MoveNext
If deSalaries.rscmdIncrementMonths.EOF = True Then
deSalaries.rscmdIncrementMonths.MoveLast
End If
monthName = txtMonths 'Get the current month that is display and convert it to a date format
monthName = (CDate(monthName))
'Write out the sql query to find all the employees under the current month
strSQL = "SELECT `Month`.`MonthName`, " & _
"LinkMonthEmployee.EmployeeNo, " & _
"LinkMonthEmployee.Surname, " & _
"LinkMonthEmployee.AccountNo, " & _
"LinkMonthEmployee.EmployeeSalary, " & _
"LinkMonthEmployee.Position, " & _
"LinkMonthEmployee.Certificate, " & _
"LinkMonthEmployee.GrossSalary, " & _
"LinkMonthEmployee.Tax, " & _
"LinkMonthEmployee.SocialSecurity, " & _
"LinkMonthEmployee.NetSalary " & _
"FROM Month, LinkMonthEmployee " & _
"WHERE `Month`.MonthID = LinkMonthEmployee.MonthID AND Month`.MonthID = '" & monthName & "' "
'Set all the properties for the data environment
deSalaries.Commands("cmdAllDetails").CommandType = adCmdText
deSalaries.Commands("cmdAllDetails").CommandText = strSQL
dgrSalaries.DataMember = "cmdAllDetails" 'Set the datamember to cmdAddDetails
dgrSalaries.ReBind 'Rebind the datagrid to display all the employees under the current month that has been incremented
end sub
Not sure where l am going wrong with the above code, but it will not work but compiles ok. Not sure if l have set all the properties in the data environment. Any help will be most gratefull in solving this problem for me.
Many thanks in advance
Steve
I am using the datagrid and data environment. But my sql query does not work. Can anyone tell me what l am doing wrong from the code below.
Private Sub cmdNext_Click()
Dim strSQL As String
Dim monthName As String
'increment the months to display each month in the year
deSalaries.rscmdIncrementMonths.MoveNext
If deSalaries.rscmdIncrementMonths.EOF = True Then
deSalaries.rscmdIncrementMonths.MoveLast
End If
monthName = txtMonths 'Get the current month that is display and convert it to a date format
monthName = (CDate(monthName))
'Write out the sql query to find all the employees under the current month
strSQL = "SELECT `Month`.`MonthName`, " & _
"LinkMonthEmployee.EmployeeNo, " & _
"LinkMonthEmployee.Surname, " & _
"LinkMonthEmployee.AccountNo, " & _
"LinkMonthEmployee.EmployeeSalary, " & _
"LinkMonthEmployee.Position, " & _
"LinkMonthEmployee.Certificate, " & _
"LinkMonthEmployee.GrossSalary, " & _
"LinkMonthEmployee.Tax, " & _
"LinkMonthEmployee.SocialSecurity, " & _
"LinkMonthEmployee.NetSalary " & _
"FROM Month, LinkMonthEmployee " & _
"WHERE `Month`.MonthID = LinkMonthEmployee.MonthID AND Month`.MonthID = '" & monthName & "' "
'Set all the properties for the data environment
deSalaries.Commands("cmdAllDetails").CommandType = adCmdText
deSalaries.Commands("cmdAllDetails").CommandText = strSQL
dgrSalaries.DataMember = "cmdAllDetails" 'Set the datamember to cmdAddDetails
dgrSalaries.ReBind 'Rebind the datagrid to display all the employees under the current month that has been incremented
end sub
Not sure where l am going wrong with the above code, but it will not work but compiles ok. Not sure if l have set all the properties in the data environment. Any help will be most gratefull in solving this problem for me.
Many thanks in advance
Steve