|
-
Nov 27th, 2005, 04:26 AM
#1
Thread Starter
New Member
[RESOLVED] Problems with INSERT INTO
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)
qdfChange.Execute
qdfChange.Close
db.Close
CrystalReport1.Destination = crptToPrinter
CrystalReport1.Action = 1
End Sub
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|