We help IT Professionals succeed at work.
Get Started

Code Correction

176 Views
Last Modified: 2013-11-25
What's Wrong with my Code? This code has been running in DataAccess but when i transfer in MSSQL7 it doesn't Work. Why?
Private Sub Savelog()
    Call LogIn
 
    
      If login_am = False And logout_am = False And login_pm = False And logout_pm = False Then
        With LogInRS
            .AddNew
                !EM_ID = txtEmployeeID.Text
                !DATE_LOG = lblDate.Caption
                !IN_AM = lblTime.Caption
                !OUT_AM = "00:00:00"
                !IN_PM = "00:00:00"
                !OUT_PM = "00:00:00"
                !TOTAL_AM = "00:00:00"
                !TOTAL_PM = "00:00:00"
                !GRAND_TOTAL = "00:00:00"
            .Update
        End With
         
        MsgBox "Employees ID: " & txtEmployeeID.Text & " has been successfully LOG IN!", vbInformation
    
    ElseIf login_am = True And logout_am = False And login_pm = False And logout_pm = False Then
        
        LogInRS.Find "LOG_ID='" + lblLogID.Caption + "'", 0, 1
        With LogInRS
                !OUT_AM = lblTime.Caption
                !TOTAL_AM = Result
                !GRAND_TOTAL = Result
            .Update
        End With
        
        MsgBox "Employees ID: " & Trim(txtEmployeeID.Text) & " has been successfully LOG OUT!", vbInformation
        
    ElseIf login_am = True And logout_am = True And login_pm = False And logout_pm = False Then
        
        LogInRS.Find "LOG_ID='" + lblLogID.Caption + "'", 0, 1
        With LogInRS
                !IN_PM = lblTime.Caption
            .Update
        End With
        
        MsgBox "Employees ID: " & Trim(txtEmployeeID.Text) & " has been successfully LOG IN!", vbInformation
    
    ElseIf login_am = True And logout_am = True And login_pm = True And logout_pm = False Then
        
        LogInRS.Find "LOG_ID='" + lblLogID.Caption + "'", 0, 1
        With LogInRS
                !OUT_PM = lblTime.Caption
                !TOTAL_PM = Result
                !GRAND_TOTAL = Result
            .Update
        End With
        
        With LogInRS
                tt1 = !TOTAL_AM
                tt2 = !TOTAL_PM
        End With
        
        COMPUTE_TOTAL = True
        Call computetime
        With LogInRS
                !GRAND_TOTAL = Result
            .Update
        End With
        
        MsgBox "Employees ID: " & Trim(txtEmployeeID.Text) & " has been successfully LOG OUT!", vbInformation
         
    ElseIf login_am = True And logout_am = True And login_pm = True And logout_pm = True Then
    
         MsgBox "Employees ID: " & Trim(txtEmployeeID.Text) & " has already logged completely  for the day!", vbInformation
    
    End If
    
    COMPUTE_TOTAL = False
    Call UnloadOject
End Sub
 
 
'''This is Correct
Public Sub LogIn()
    Set LogInRS = New ADODB.Recordset
    With LogInRS
        .ActiveConnection = conn
        .CursorType = adOpenStatic
        .LockType = adLockOptimistic
        .Open "SELECT * FROM TIMELOG"
    End With
End Sub

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE