martialdc
Feb 26th, 2006, 07:43 PM
i have this code in the form;
Public Function connectDB() As ADODB.Connection
Set connectDB = New ADODB.Connection
connectDB.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & App.Path & "\dbPayroll.mdb;Uid=Admin;Pwd=;"
connectDB.Open
End Function
Private Sub btnClose_Click()
Unload Me
End Sub
Private Sub btnPreview_Click()
copyToTempDTR
If DataEnvironment.rsEmployee.State = adStateClosed Then
DataEnvironment.rsEmployee.Open
Else
DataEnvironment.rsEmployee.Close
DataEnvironment.rsEmployee.Open
End If
'
DataEnvironment.rsEmployee.Requery
rptDTR.Sections(1).Controls("lblDate").Caption = Format(dtpFrom.Value, "mmmm dd, yyyy") & " - " & Format(dtpTo.Value, "mmmm dd, yyyy")
rptDTR.Show 1
End Sub
Private Sub copyToTempDTR()
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim intCount As Integer
Set con = connectDB
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open "DELETE * from tmpDTR", con
.Open "INSERT INTO tmpDTR ( dDate, EmployeeID, TimeInAM, TimeOutAM, TimeInPM, TimeOutPM, RegularHours, OvertimeHours, Vale )SELECT tblDTR.dDate, tblDTR.EmployeeID, tblDTR.TimeInAM, tblDTR.TimeOutAM, tblDTR.TimeInPM, tblDTR.TimeOutPM, tblDTR.RegularHours, tblDTR.OvertimeHours, tblDTR.Vale FROM tblDTR Where dDate>=#" & dtpFrom.Value & "# And dDate<=#" & dtpTo.Value & "#;", con
.Open "Select * from tmpDTR", con
.Close
End With
con.Close
Set rs = Nothing
Set con = Nothing
End Sub
>>My problem is this code.. Sometimes I have to click the Preview button twice of even thrice to view the exact record that i need to display in datareport?? kindly help me pls??? attached with this thread is the report that im doing..
Private Sub btnPreview_Click()
copyToTempDTR
If DataEnvironment.rsEmployee.State = adStateClosed Then
DataEnvironment.rsEmployee.Open
Else
DataEnvironment.rsEmployee.Close
DataEnvironment.rsEmployee.Open
End If
'
DataEnvironment.rsEmployee.Requery
rptDTR.Sections(1).Controls("lblDate").Caption = Format(dtpFrom.Value, "mmmm dd, yyyy") & " - " & Format(dtpTo.Value, "mmmm dd, yyyy")
rptDTR.Show 1
End Sub
thanks in advance..
Public Function connectDB() As ADODB.Connection
Set connectDB = New ADODB.Connection
connectDB.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & App.Path & "\dbPayroll.mdb;Uid=Admin;Pwd=;"
connectDB.Open
End Function
Private Sub btnClose_Click()
Unload Me
End Sub
Private Sub btnPreview_Click()
copyToTempDTR
If DataEnvironment.rsEmployee.State = adStateClosed Then
DataEnvironment.rsEmployee.Open
Else
DataEnvironment.rsEmployee.Close
DataEnvironment.rsEmployee.Open
End If
'
DataEnvironment.rsEmployee.Requery
rptDTR.Sections(1).Controls("lblDate").Caption = Format(dtpFrom.Value, "mmmm dd, yyyy") & " - " & Format(dtpTo.Value, "mmmm dd, yyyy")
rptDTR.Show 1
End Sub
Private Sub copyToTempDTR()
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim intCount As Integer
Set con = connectDB
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open "DELETE * from tmpDTR", con
.Open "INSERT INTO tmpDTR ( dDate, EmployeeID, TimeInAM, TimeOutAM, TimeInPM, TimeOutPM, RegularHours, OvertimeHours, Vale )SELECT tblDTR.dDate, tblDTR.EmployeeID, tblDTR.TimeInAM, tblDTR.TimeOutAM, tblDTR.TimeInPM, tblDTR.TimeOutPM, tblDTR.RegularHours, tblDTR.OvertimeHours, tblDTR.Vale FROM tblDTR Where dDate>=#" & dtpFrom.Value & "# And dDate<=#" & dtpTo.Value & "#;", con
.Open "Select * from tmpDTR", con
.Close
End With
con.Close
Set rs = Nothing
Set con = Nothing
End Sub
>>My problem is this code.. Sometimes I have to click the Preview button twice of even thrice to view the exact record that i need to display in datareport?? kindly help me pls??? attached with this thread is the report that im doing..
Private Sub btnPreview_Click()
copyToTempDTR
If DataEnvironment.rsEmployee.State = adStateClosed Then
DataEnvironment.rsEmployee.Open
Else
DataEnvironment.rsEmployee.Close
DataEnvironment.rsEmployee.Open
End If
'
DataEnvironment.rsEmployee.Requery
rptDTR.Sections(1).Controls("lblDate").Caption = Format(dtpFrom.Value, "mmmm dd, yyyy") & " - " & Format(dtpTo.Value, "mmmm dd, yyyy")
rptDTR.Show 1
End Sub
thanks in advance..