Zippersabrat
Blah Blah Blah :o)
- Local time
- Today, 11:56
- Joined
- May 5, 2010
- Messages
- 31
This is mainly a formating question: I have the following wordy, messy code in a database. Code works great but I know there is a better way to write it. Can anyone offer some shortcuts for this code? Thanks!
Code:
Private Sub Form_Close()
Dim SQLA1 As String
Dim SQLA2 As String
Dim SQLA3 As String
Dim SQLA4 As String
Dim SQLA5 As String
Dim SQLA6 As String
Dim SQLA7 As String
Dim SQLA8 As String
Dim SQLA9 As String
Dim SQLAX As String
SQLA1 = "Update InventoryList " & _
"SET [AreaAssignment]='Area1' " & _
"WHERE ([LocationCode] Like 'BR*' OR [LocationCode] Like 'MC*' " & _
"OR [LocationCode] Like 'B1*' OR [LocationCode] Like 'LR*' " & _
"OR [LocationCode] Like 'G-A8*' OR [LocationCode] Like 'G-A9*' OR [LocationCode] Like 'G-Mis*')"
SQLA2 = "Update InventoryList " & _
"SET [AreaAssignment]='Area2' " & _
"WHERE ([LocationCode] Like 'G-A1*' OR [LocationCode] Like 'G-A2*' " & _
"OR [LocationCode] Like 'G-A3*' OR [LocationCode] Like 'G-A4*' " & _
"OR [LocationCode] Like 'G-A5*' OR [LocationCode] Like 'G-A6*' OR [LocationCode] Like 'G-A7*')"
SQLA3 = "Update InventoryList " & _
"SET [AreaAssignment]='Area3' " & _
"WHERE ([LocationCode] Like 'L1*')"
SQLA4 = "Update InventoryList " & _
"SET [AreaAssignment]='Area4' " & _
"WHERE ([LocationCode] Like 'L2*' OR [LocationCode] Like 'T-D*' " & _
"OR [LocationCode] Like 'T-A*' OR [LocationCode] Like 'T-BLC*' " & _
"OR [LocationCode] Like 'T-Sh*' OR [LocationCode] Like 'T-W*')"
SQLA5 = "Update InventoryList " & _
"SET [AreaAssignment]='Area5' " & _
"WHERE ([LocationCode] Like 'CA*' OR [LocationCode] Like 'G-Br*' " & _
"OR [LocationCode] Like 'Mark*' OR [LocationCode] Like 'EXRm-S*')"
SQLA6 = "Update InventoryList " & _
"SET [AreaAssignment]='Area6' " & _
"WHERE ([LocationCode] Like 'Ph-D*' OR [LocationCode] Like 'Ph-LC*' " & _
"OR [LocationCode] Like 'Ph-Co*' OR [LocationCode] Like 'Ph-Mis*' " & _
"OR [LocationCode] Like 'LBO*' OR [LocationCode] Like 'LBT*')"
SQLA7 = "Update InventoryList " & _
"SET [AreaAssignment]='Area7' " & _
"WHERE ([LocationCode] Like 'Ph-UC*')"
SQLA8 = "Update InventoryList " & _
"SET [AreaAssignment]='Area8' " & _
"WHERE ([LocationCode] Like 'IA*' OR [LocationCode] Like 'P1*' " & _
"OR [LocationCode] Like 'P2*' OR [LocationCode] Like 'Sx-*')"
SQLA9 = "Update InventoryList " & _
"SET [AreaAssignment]='Area9' " & _
"WHERE ([LocationCode] Like 'T-Fr*' OR [LocationCode] Like 'T-LC*' " & _
"OR [LocationCode] Like 'T-RC*' OR [LocationCode] Like 'T-RD*' " & _
"OR [LocationCode] Like 'T-UC1*' OR [LocationCode] Like 'T-UC2*')"
SQLAX = "Update InventoryList " & _
"SET [AreaAssignment]='Area10' " & _
"WHERE ([LocationCode] Like 'T-UC3*' OR [LocationCode] Like 'T-UC4*' " & _
"OR [LocationCode] Like 'T-UC6*' OR [LocationCode] Like 'T-View*' " & _
"OR [LocationCode] Like 'T-UCD*' OR [LocationCode] Like 'T-Cou*' " & _
"OR [LocationCode] Like 'T-UC5*' OR [LocationCode] Like 'T-Mu*' OR [LocationCode] Like 'T-Mis*')"
DoCmd.SetWarnings False
DoCmd.RunSQL SQLA1
DoCmd.RunSQL SQLA2
DoCmd.RunSQL SQLA3
DoCmd.RunSQL SQLA4
DoCmd.RunSQL SQLA5
DoCmd.RunSQL SQLA6
DoCmd.RunSQL SQLA7
DoCmd.RunSQL SQLA8
DoCmd.RunSQL SQLA9
DoCmd.RunSQL SQLAX
DoCmd.SetWarnings True
End Sub