I have the following subroutine that inserts data from one table into another table and totals it up
I am trying to modify it so that it doesn't put one particular field in the table but reads the username from the person logged onto the program
Private Sub Command2_Click()
Dim db As Database
Dim sql As String
Dim qdfChange As QueryDef
Set db = OpenDatabase("z:\BarDb97_be.mdb", False, False, ";pwd=backdoor")
db.Execute "DELETE * FROM viewfinalbill"
sql = "INSERT INTO ViewFinalBill ( Description, location, binno, Quantity, total, customer ) SELECT actionbill.description, gUserid$, actionbill.binno, Sum(actionbill.quantity) AS quantity, Sum(actionbill.total) AS total, Last(actionbill.customer) AS customer From actionbill GROUP BY actionbill.description, actionbill.binno, gUserid$ HAVING (((Count(actionbill.description))>0) AND ((actionBill.binno) = '" & gBinNo & "'));"
Set qdfChange = db.CreateQueryDef("", sql)
I have two locations and users both called Upstairs, Downstairs I have a variable gUserid$ that reads the usename, I am trying to post that into the location field of viewfinalbill, but it still insists on pulling out the location field from actionbill, this is making me go spare. If anybody can help me I'd be grateful