I have a subroutine for creating new timecards for employees. It works fine except that I can't get it to assign a unique timecard number (per employee). So far this particular employee has timecards 1 through 6. To find a unique timecard number for the employee, I keep looping until it finds a timecard number that doesn't exist. However, the loop always stops at 6, even though several timecards for that employee already exist as # 6.
The relevant code is below:
Does anybody see something wrong with the code?
Also, does it matter if an employee has multiple timecards with the same number? I don't really care if I make a timecard 6 for employee "Joe Smith" in week 1, and another timecard 6 for same employee in week 2, the week he gets paid, so long as the cheque includes both timecards.
The relevant code is below:
Code:
Set linkCompany = Ses.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
' Timecard Header
linkCompany.OpenView "CP0031", headerView
Set headerFields = headerView.Fields
' Timecard Detail
linkCompany.OpenView "CP0032", detailView
Set detailFields = detailView.Fields
headerView.Compose Array(detailView)
detailView.Compose Array(headerView)
' Create a new TimecardNo
lngTimecardNo = 1
headerView.Browse "Employee = """ & txtEmployeeID & """ AND Timecard = """ & CStr(lngTimecardNo) & """", True
[COLOR=red]'My loop to find a unique timecard number for this employee[/color]
Do While (headerView.Fetch)
lngTimecardNo = lngTimecardNo + 1
headerView.Browse "Employee = """ & txtEmployeeID & """ AND Timecard = """ & CStr(lngTimecardNo) & """", True
Loop
' No Timecard exists for that employee with this timecard number, so use it for a new
' timecard
txtTimecardID = lngTimecardNo
Does anybody see something wrong with the code?
Also, does it matter if an employee has multiple timecards with the same number? I don't really care if I make a timecard 6 for employee "Joe Smith" in week 1, and another timecard 6 for same employee in week 2, the week he gets paid, so long as the cheque includes both timecards.