Hello,
I have an application that I built that I am having a most difficult time with. The application is an employee number generation app designed to generate employee numbers for three companies. The front end is Visual Basuc 6 and the back end is MS-SQL.
I store employee information in the form of the employee's name, ID number, start date, etc., the first letter of the employee's last name is used to select a group and then a filter and Max function is used to select the highest employee number. After the highest number is selected it is incremented and saved back to the employees table and then the front end screen is updated.
I am using ADO to connect to the MS-SQL tables, my query is: EHRS.Open "SELECT EmpHistory.EmpHist_ID, " _
& "EmpHistory.EIDNUM, " _
& "EmpHistory.EIDNUMBarCode, " _
& "EmpHistory.empLName, " _
& " EmpHistory.empComp, " _
& "EmpHistory.Time, " _
& "EmpHistory.LastUpdate_ts " _
& "FROM EmpHistory " _
& "WHERE (((EmpHistory.empComp) = '" & Company & "')) AND " _
& "(EmpHistory.empLName LIKE '%" & LastName & "%' AND " _
& "EIDNUM NOT LIKE '%" & 199 & "%')" _
, db, adOpenKeyset, adLockOptimistic
If EHRS.BOF = True And EHRS.EOF = True Then
Do While Not EHRS.EOF
If EHRS!EIDNUM <> moEmpNum Then
SintRC = EHRS!EIDNUM
SintRC = SintRC + 1
EHRS.MoveNext
End If
Loop
As you can see I am trying to loop through the record set and get the highest employee number given the first letter of the employee's last name. This will work and some times it will not work, the query will return the employee number that is maybe the first number or the second to the last number, it is inconsistent.
Does anybody know what is wrong, I have tried different constructs but no luck...
I have an application that I built that I am having a most difficult time with. The application is an employee number generation app designed to generate employee numbers for three companies. The front end is Visual Basuc 6 and the back end is MS-SQL.
I store employee information in the form of the employee's name, ID number, start date, etc., the first letter of the employee's last name is used to select a group and then a filter and Max function is used to select the highest employee number. After the highest number is selected it is incremented and saved back to the employees table and then the front end screen is updated.
I am using ADO to connect to the MS-SQL tables, my query is: EHRS.Open "SELECT EmpHistory.EmpHist_ID, " _
& "EmpHistory.EIDNUM, " _
& "EmpHistory.EIDNUMBarCode, " _
& "EmpHistory.empLName, " _
& " EmpHistory.empComp, " _
& "EmpHistory.Time, " _
& "EmpHistory.LastUpdate_ts " _
& "FROM EmpHistory " _
& "WHERE (((EmpHistory.empComp) = '" & Company & "')) AND " _
& "(EmpHistory.empLName LIKE '%" & LastName & "%' AND " _
& "EIDNUM NOT LIKE '%" & 199 & "%')" _
, db, adOpenKeyset, adLockOptimistic
If EHRS.BOF = True And EHRS.EOF = True Then
Do While Not EHRS.EOF
If EHRS!EIDNUM <> moEmpNum Then
SintRC = EHRS!EIDNUM
SintRC = SintRC + 1
EHRS.MoveNext
End If
Loop
As you can see I am trying to loop through the record set and get the highest employee number given the first letter of the employee's last name. This will work and some times it will not work, the query will return the employee number that is maybe the first number or the second to the last number, it is inconsistent.
Does anybody know what is wrong, I have tried different constructs but no luck...