C
Chipmunkwhiz
I am trying to set up some code to renumber customer
lists. I am self taught, so I apologise if this is
impossible this way.
I am trying to set variables and then use them in an
update Query. Could someone set me on the right path?
Dim MaxID, MinID, ExistDif, MinNewID As Long
Dim StrSQL As String
'set variables
MaxID = DMax("ID", "Customer Table", "([customer table].
[Delivery Route])=[Forms]![MainMainform]![MainMenu].
[Form]![CustomerListFilter]")
MinID = DMin("ID", "Customer Table", "([customer table].
[Delivery Route])=[Forms]![MainMainform]![MainMenu].
[Form]![CustomerListFilter]")
ExistDif = MaxID - MinID
MinNewID = ([Forms]![MainMainform]![MainMenu].[Form]!
[CustomerListFilter] - 1) * 1000
'set SQL
StrSQL = "UPDATE [Customer Table] SET [Customer Table].ID
= ((1000 * ([Customer table].ID - MinID) / ExistDif) +
MinNewID) WHERE ((([customer table].[Delivery Route])=
[Forms]![MainMainform]![MainMenu].[Form]!
[CustomerListFilter]));"
CurrentDb.Execute StrSQL, [dbFailOnError]
lists. I am self taught, so I apologise if this is
impossible this way.
I am trying to set variables and then use them in an
update Query. Could someone set me on the right path?
Dim MaxID, MinID, ExistDif, MinNewID As Long
Dim StrSQL As String
'set variables
MaxID = DMax("ID", "Customer Table", "([customer table].
[Delivery Route])=[Forms]![MainMainform]![MainMenu].
[Form]![CustomerListFilter]")
MinID = DMin("ID", "Customer Table", "([customer table].
[Delivery Route])=[Forms]![MainMainform]![MainMenu].
[Form]![CustomerListFilter]")
ExistDif = MaxID - MinID
MinNewID = ([Forms]![MainMainform]![MainMenu].[Form]!
[CustomerListFilter] - 1) * 1000
'set SQL
StrSQL = "UPDATE [Customer Table] SET [Customer Table].ID
= ((1000 * ([Customer table].ID - MinID) / ExistDif) +
MinNewID) WHERE ((([customer table].[Delivery Route])=
[Forms]![MainMainform]![MainMenu].[Form]!
[CustomerListFilter]));"
CurrentDb.Execute StrSQL, [dbFailOnError]