In rough order;
1. Where you have 'Consumed' Status, your database is probably interpreting this as a user-defined field. By
entering 'Consumed' Status, you're basically saying "display a column called Status and enter 'Consumed' as its
value".
For example, "select 'Andy' as Name" will display a column called name and fill in the value 'Andy'.
Upper converts the value you pass to it to upper-case, usually for case-sensitive comparison purposes. So,
Upper('andy') returns 'ANDY'.
2. & is used by VBScript/VB/VBA to concatenate a string; that is "My" & "String" becomes "MyString". Be careful
not to mix up & and + and check your database documentation for the differences between concatentation and
addition operators, otherwise you might get some funny results.
3. The statement you're building is a string that will probably be passed to a database to execute, hence the &
operators. The underscore means "continue on this line" and is just a way of breaking a single statement down
onto multiple lines.
So;
statement1 _
statement2 _
statement3
is the same as statement1 statement2 statement3
4. DESC is SQL for "order this field in descending order" - ASC I assume means ascending, though this is the
default and I've never seen it used before.
5. This is VBScript/VB/VBA for "end a while conditional loop" - it needs to accompany a While statement;
for example;
While (Not rs.EOF)
' do statements
rs.MoveNext
WEnd
Hope this helps.