Hello,
I am creating an application that alters reservation database information for a restaurant. The variables are all declared public and used in multiple procedures. I am having an issue while running a certain code that assigns reservations to a table. The program updates a record in the reservation with table information and guest count information. The problem I am having is the variable assigned to the row number increases value after updating the adult count column. So the next column to update, which is the junior count, gets updated on the next row of the database rather than the current/correct row. There is no code in between that would cause the row number to change. I am posting the code below and would appreciate someone's help. The variable in question is "row1".
The error occurs after completing line
and changes at line
Thanks for your help!
I am creating an application that alters reservation database information for a restaurant. The variables are all declared public and used in multiple procedures. I am having an issue while running a certain code that assigns reservations to a table. The program updates a record in the reservation with table information and guest count information. The problem I am having is the variable assigned to the row number increases value after updating the adult count column. So the next column to update, which is the junior count, gets updated on the next row of the database rather than the current/correct row. There is no code in between that would cause the row number to change. I am posting the code below and would appreciate someone's help. The variable in question is "row1".
Code:
Application.ScreenUpdating = False
On Error GoTo Error:
If Range("Tables_eFloorplan").Find(What:="*," & t1 & "(*", LookIn:=xlValues) Is Nothing Then
gc1 = Sheets("Reservations").Cells(row1, Range("Count_PartyActual").Column) - Sheets("Reservations").Cells(row1, Range("Count_PartyAssigned").Column)
ac1 = Sheets("Reservations").Cells(row1, Range("Count_AdultActual").Column) - Sheets("Reservations").Cells(row1, Range("Count_AdultAssigned").Column)
cc1 = Sheets("Reservations").Cells(row1, Range("Count_ChildActual").Column) - Sheets("Reservations").Cells(row1, Range("Count_ChildAssigned").Column)
ic1 = Sheets("Reservations").Cells(row1, Range("Count_InfantActual").Column) - Sheets("Reservations").Cells(row1, Range("Count_InfantAssigned").Column)
If Sheets("Reservations").Cells(row1, Range("Tables_eFloorplan").Column).value = vbNullString Then
Sheets("Reservations").Cells(row1, Range("Tables_eFloorplan").Column) = "," & t1 & "(" & gc1 & "/" & ac1 & "a0j" & cc1 & "c" & ic1 & "i)"
Else
Sheets("Reservations").Cells(row1, Range("Tables_eFloorplan").Column) = Sheets("Reservations").Cells(row1, Range("Tables_eFloorplan").Column) & "," & t1 & "(" & gc1 & "/" & ac1 & "a0j" & cc1 & "c" & ic1 & "i)"
End If
Else
MsgBox "Table already assigned"
End If
Sheets("Reservations").Cells(row1, Range("Count_AdultAssigned").Column) = Sheets("Reservations").Cells(row1, Range("Count_AdultAssigned").Column) + ac1
Sheets("Reservations").Cells(row1, Range("Count_ChildAssigned").Column) = Sheets("Reservations").Cells(row1, Range("Count_ChildAssigned").Column) + cc1
Sheets("Reservations").Cells(row1, Range("Count_InfantAssigned").Column) = Sheets("Reservations").Cells(row1, Range("Count_InfantAssigned").Column) + ic1
Sheets("Reservations").Cells(row1, Range("Status_Reservation").Column).value = "Assigned"
With Application.WorksheetFunction
Sheets("Reservations").Cells(row1, Range("Notes_History").Column).value = "Assigned to table " & t1 & " by [" & .Index(Range("User_LAN"), .Match(Range("User_Active"), Range("User_PERNER"), 0)) & " : " & Now & "]" & Chr(10) & Chr(10) & Sheets("Reservations").Cells(row1, Range("Notes_History").Column).value
End With
Run "Selection_Clear"
Exit Sub
Error:
subname = "'Tables_Assign'"
Run "Error_Report"
End Sub
The error occurs after completing line
Code:
Sheets("Reservations").Cells(row1, Range("Count_AdultAssigned").Column) = Sheets("Reservations").Cells(row1, Range("Count_AdultAssigned").Column) + ac1
and changes at line
Code:
Sheets("Reservations").Cells(row1, Range("Count_ChildAssigned").Column) = Sheets("Reservations").Cells(row1, Range("Count_ChildAssigned").Column) + cc1
Thanks for your help!