Results 1 to 4 of 4

Thread: dataenvironment problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Pilipinas
    Posts
    441

    dataenvironment problem

    i have this code in the form;

    VB Code:
    1. Public Function connectDB() As ADODB.Connection
    2.     Set connectDB = New ADODB.Connection
    3.     connectDB.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & App.Path & "\dbPayroll.mdb;Uid=Admin;Pwd=;"
    4.     connectDB.Open
    5. End Function
    6.  
    7. Private Sub btnClose_Click()
    8.     Unload Me
    9. End Sub
    10.  
    11. Private Sub btnPreview_Click()
    12.  
    13. copyToTempDTR
    14.  
    15. If DataEnvironment.rsEmployee.State = adStateClosed Then
    16.     DataEnvironment.rsEmployee.Open
    17. Else
    18.     DataEnvironment.rsEmployee.Close
    19.     DataEnvironment.rsEmployee.Open
    20. End If
    21. '
    22. DataEnvironment.rsEmployee.Requery
    23.  
    24. rptDTR.Sections(1).Controls("lblDate").Caption = Format(dtpFrom.Value, "mmmm dd, yyyy") & " - " & Format(dtpTo.Value, "mmmm dd, yyyy")
    25. rptDTR.Show 1
    26. End Sub
    27.  
    28. Private Sub copyToTempDTR()
    29.     Dim con As ADODB.Connection
    30.     Dim rs As ADODB.Recordset
    31.     Dim intCount As Integer
    32.    
    33.     Set con = connectDB
    34.     Set rs = New ADODB.Recordset
    35.     With rs
    36.        
    37.         .CursorLocation = adUseClient
    38.         .LockType = adLockOptimistic
    39.         .Open "DELETE * from tmpDTR", con
    40.         .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
    41.         .Open "Select * from tmpDTR", con
    42.                
    43.         .Close
    44.        
    45.     End With
    46.    
    47.     con.Close
    48.     Set rs = Nothing
    49.     Set con = Nothing
    50.  
    51. 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..

    VB Code:
    1. Private Sub btnPreview_Click()
    2.  
    3. copyToTempDTR
    4.  
    5. If DataEnvironment.rsEmployee.State = adStateClosed Then
    6.     DataEnvironment.rsEmployee.Open
    7. Else
    8.     DataEnvironment.rsEmployee.Close
    9.     DataEnvironment.rsEmployee.Open
    10. End If
    11. '
    12. DataEnvironment.rsEmployee.Requery
    13.  
    14. rptDTR.Sections(1).Controls("lblDate").Caption = Format(dtpFrom.Value, "mmmm dd, yyyy") & " - " & Format(dtpTo.Value, "mmmm dd, yyyy")
    15. rptDTR.Show 1
    16. End Sub

    thanks in advance..
    Attached Files Attached Files

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: dataenvironment problem

    How about...

    VB Code:
    1. Private Sub btnPreview_Click()
    2.  
    3. copyToTempDTR
    4.  
    5. If DataEnvironment.rsEmployee.State = adStateClosed Then
    6.     DataEnvironment.rsEmployee.Open
    7. Else
    8.     DataEnvironment.rsEmployee.Close
    9.     DataEnvironment.rsEmployee.Open
    10. End If
    11. '
    12. DataEnvironment.rsEmployee.Requery
    13.  
    14. rptDTR.Sections(1).Controls("lblDate").Caption = Format(dtpFrom.Value, "mmmm dd, yyyy") & " - " & Format(dtpTo.Value, "mmmm dd, yyyy")
    15. [B]rptDTR.Refresh[/B]
    16. rptDTR.Show 1
    17. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: dataenvironment problem

    Moved to reporting section

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Pilipinas
    Posts
    441

    Re: dataenvironment problem

    VB Code:
    1. rptDTR.Refresh
    2. rptDTR.Show 1

    this code still doesnt work?? i still have to click the preview button twice??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width