Hi guys, i have a small problem...
The coding works well but it have logic error, let say i have 5 reservation and the database will contain RSV001-RSV005. If i delete RSV002 from the database, and wanted to create a new reservation. The system will automatically will generate RSV005 although there is already a RSV005 in the database, because it count the number of record in the database and not the current reserve id. So how do i overcome this? Please help!!
Call QuickReservation
With QReservation
If .RecordCount = 0 Then 'If there are no records in the table
strCode = "RSV0001"
Else
'Calculating the number of records and storing in a variable
iNumofRecords = .RecordCount
iNumofRecords = iNumofRecords + 1 'incrementing the number by 1
If iNumofRecords < 10 Then
strCode = "RSV000" & iNumofRecords
ElseIf iNumofRecords < 100 Then
strCode = "RSV00" & iNumofRecords
ElseIf iNumofRecords < 1000 Then
strCode = "RSV0" & iNumofRecords
ElseIf iNumofRecords < 10000 Then
strCode = "RSV" & iNumofRecords
End If
End If
.Requery 'Requerying the Table
.AddNew 'Adding a new recordset
End With
q_id.Text = strCode