Code:
'my shop database is located at: mydb = "C:\Program Files\Actinic V8\Sites\Site1\ActinicCatalog.mdb" Set OBJdbConnection2 = CreateObject("ADODB.Connection") OBJdbConnection2.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & mydb SQLQuery2 = "SELECT [ProductReference],[QuantityOrdered] FROM [OrderDetail] WHERE [ProductReference] LIKE '" & thisprodref & "'" Set Result2 = OBJdbConnection2.Execute(SQLQuery2) if Not Result2.EOF then Do While Not Result2.EOF thiscount = thiscount + Result2("QuantityOrdered") Result2.MoveNext Loop end if OBJdbConnection2.Close
prerequisite knowledge:
- vbscript
- sql
this example only counts how many times a specific product ref has been ordered. 'thisprodref' in the sql is the product reference.
have fun.
Comment