Running SQL From Another SQL
Oct 8, 2005
Hi
I want to open a DAO.Recordset from an opened DAO.Recordset.
My code is like this
Dim db As DAO.Database
Dim rs, rsMarks As DAO.Recordset
Dim strSQL, strMarks As String
Set db = CurrentDb()
strSQL = "SELECT Name, SurName, Marks from Table1"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
strMarks = "Select Sum(Marks) As MarksSum from rs"
Set rsMarks = db.OpenRecordset(strMarks, dbOpenSnapshot)
rs.MoveFirst
Me.txtName = rs!Name
Me.txtMarks = rs!Marks
Me.txtSurName = rs!SurName
rsMarks.MoveFirst
Me.txtMarksSum = rsSur!MarksSum
rs.Close
rsSur.Close
db.Close
Set rs = Nothing
Set rsSur = Nothing
Set db = Nothing
But I got an error message “The Microsoft Jet Database engine can not find the input table or query ‘rs’. Make sure input table or query exist”
While without this second 'rsMarks' my first SQL 'rs' works well
I will be grateful if any one help me.
Regards
Rahulgty
View Replies
ADVERTISEMENT
Mar 14, 2005
Can anyone tell me how to get a running balance on a report. I know how to create a running total, by setting the "running sum" property of a text box to "Over all".
I can't however see how I can adapt this to give a running balance (as in a bank statement for example). Attempts to do so end up in failure!!
Many thanks in advance.
Peter
View 2 Replies
View Related
May 15, 2006
Is there a function for cumulative row for use in querys (calculated field) or in a code - something like "running sum" in reports?
View 2 Replies
View Related
Apr 12, 2005
Forgive the Bonehead question. I know this is probably easy, and may have been answered before, but I'm under the gun and trying to get this done quickly.
I have a form that is populated from a table. Each record has a Yes/No value (called "Matched") and a $ amount (called "PaymentAmount"). When they open the form, all the "Matched" records are a No (or False) value. I want a Text Box called "Total_Matched" to keep a running total of all "PaymentAmount" when they check the "Matched" field.
Does this make sense?
I have done a query that gives a sum of PaymentAmount from the table where all values are "True", but I can't get it to requery each time they check the boxes. And I can get a Total of all values on the form (=Sum([PaymentAmount]) but I can't make it contingent on if the Matched field is true.
Any help is greatly appreciated. I'm off to search some more.
Thanks.
View 1 Replies
View Related
Jun 24, 2005
I am using Access 2003 but it is to slow, what can I do?
View 1 Replies
View Related
Jan 23, 2006
Hi Folks,
I want to automate the Nero burner from a Microsoft Office Access Database. I have the code to close the DB and then open the nero program, but i dont know how to actually run a complete burning action from the same click of a button in the DB. I'm working from a macro at the moment but open to suggestions... batch files etc
Cheers Oldtimer
View 1 Replies
View Related
Aug 2, 2006
Question:
Is it possible to see if a database has stopped running (errored out, timed out, or if code builder is open) thru another database. I know how to look for the .LDB file to see if the database is open...but is it possible to know if it's broken?
The reason I ask is that I have a database on a pc (can't be put on a network) that updates/refreshes every 5 minutes. Once in awhile someone will do something and cause the database to halt (code builder window opens). Currently the way I check to see if the database is running is to VNC onto the pc from my pc and see if it's running. Does this make since?
DT
View 2 Replies
View Related
Feb 12, 2007
Hello,
I have a report which is similar to a bank statement. I have a transaction date and then either a credit or debit depending on whether the customer made a payment or if I am invoicing them.
I have created an additional field in the report which calculates AmountDue - TotalPaymentAmount and called this field Balance.
I then attributed a running sum based on this Balance field.
This works great.................BUT!!!!!
If a customer has 100 transactions the report will be well over 10 pages long.
Is there a way I can limit the report to just perhaps the most recent 20 transactions or 20 days?
I tried and failed in the report's query retrieve the payments which occur >datenow(-20) (basically in the last 20 days). This worked ok in the sense that only the last 20 days worth of transactions appeared in the report......BUT!......the first running sum of the report does not carry over from the previous transaction..it starts from 0!!!!
Please help me get over the RUNNING SUM blues!
Rob
View 4 Replies
View Related
Dec 11, 2007
Hi there!I am having a fair amount of trouble figuring this out, and I was hoping someone might know what I was doing wrong. Someone set up a switchboard (I think using the Switchboard wizard) in this Access DB. I've since taken on the project of automating a database process and I want to use a switchboard item so it's a one-click, otherwise mostly automatic process. I have added the switchboard item, and when I click on it I get a msgbox displaying with my test text, so I think that is set up OK.Right now, I am trying to have a click on the button launch a custom sub (that I still have to write). Right now all I have in that sub is another call to a Msgbox with other testing text.Following is the relevant VBA code - not all of it, but I think this is all that will be involved. runDeletions() is located in its own module "Module3":The Sub:Public Sub runDeletions() MsgBox "testing - runDeletions ran successfully" End Sub This is the code in the switchboard form that deals with the arguments taken - and that will call the above function. Code within Private Function HandleButtonClick(intBtn As Integer): '...have the argument set to 8...Const conCmdRunCode = 8 '... so this Case will run:Case conCmdRunCode ' optional, just tells me the value of the argument being used' MsgBox rs![Argument] 'actually is what tries to call the Sub Application.Run rs![Argument] I've found the Switchboard Items table, and added in the following record. It hasSwitchboardID as: 3 (this button is on its own page)ItemNumber as: 1Itemtext as: Run Pending DeletionsCommand as: 8Argument as: Module3.runDeletions()I'm pretty sure my Argument is wrong. I've tried a few things but can't figure it out. What could I use as my Argument so my sub runDeletions in my module Module3 will run when this button is clicked?Thanks!PS - I've also posted this question here: http://www.vbaexpress.com/forum/showthread.php?t=16611 and any differences in code are intentional, as I keep trying different things (but so far no luck)...
View 3 Replies
View Related
Jan 27, 2008
Hi,
I'm sending an e-mail each time a spesific report is made. If the user has'nt opened Outlook, it is placed in Outlook's Outbox, and is sent first when the user opens Outlook. Can I somehow start Outlook using VBA so the email gets sent when the report is run?
Also, The user is prompted with a warning message that an application tries to send an email. The user has to allow this for the mail to be sent. I know this is a security matter so no applicatopn can send emails without the user knowing. Is there someway to do this without the warning?
I'm using WXP and A2K3
Thanks in advance.
View 5 Replies
View Related
Feb 26, 2008
Hi Chaps
Probably one of those numpy questions but does anyone know how to run a database minimised?
I have a scheduled task that needs to run every 30 minutes which it does beautifully, however the database window pops up over whatever I'm doing at the time.
Not a huge problem but if anyone has a solution?
Extra info: The scheduled task calls a .bat file that runs the database and transfers data to a web site.
Thanks
Paul
View 4 Replies
View Related
Sep 16, 2005
Hi!
Sorry I am to bother you. But I was wondering whether it is possible to create a running sum in a query (from each previous record just a simple add up)?
I know how to do in report (it is described in the help function) but for a query I cannot find anything.
Thx and rgds,
Lobhaan
View 2 Replies
View Related
Feb 16, 2006
have a table, Loans.
Fields:
ID (key)
Loan Number
Principal Balance.
I have another table, Transaction, that's based off the Loan Number field on the loans table.
Fields:
LoanNumber
Payment Type (2 choices, payment and advance)
Amount
I have a user form where users can specify the payment type, and amount, based on a certain loan number.
I'm attempting to do this:
User enters a transaction into the database. once the transaction is entered, the Principal Balance field for the specified loan number is updated.
If the payment type is advance, the query will subtract the amount from principalbalnce. if payment, the query wll add the amount to the principal balance.
Here's what I have so far.
The userform updates the transactions table with the information correctly.
My next step is to update the principal balance.
I'm thinking I could use some sort of update query, but I don't know where to begin.
HELP!!
If there is a better (normalized) way to accomplish this, I'm definitely open to ideas. Please just provide a basic example so I can understand. :o :cool:
View 1 Replies
View Related
May 22, 2006
I need to update a ytd-budget field using the curmo-budget field. The table contains one record for each month. The ytd-budget for Jan would be the same as curmo-bud for Jan. Feb's ytd would be the sum of Jan + Feb...etc. Is there a way to update the ytd fields with a 'running sum' feature as found in the report options?
(... unfamiliar with VB). Thanks
View 11 Replies
View Related
Jul 7, 2006
Hi,
I did 2 ways:
If I created a query named qry1,
then, I created another query (qry2) which include qry1.
Is that meaning running 2 queries?
Firstly, run qry1 result, then run qry2.
Please let me know, thanks.
View 3 Replies
View Related
Jul 29, 2006
Well Shut down my computer and call me a newbie.
I'm trying to run an append query with two parameters and a like "value*" in the where clause. When I run it in ADO it returns no values.
When I run it in DAO is works just fine.
WHen I delete the like condition it works just fine.
When I change the like condition to and abolute condition, e.g. "Cancel" it works just fine.
BUT WHEN I PUT Like "Can*" back it is returns no records.
Now I've been working with Access for more years than I will admit, but I have never seen anything like this.
I assume Like is valid SQL
SO SOMEONE PUT ME OUT OF MY MISERY. Am I barking up the wrong dog, or is "Like 'XXX*" not usable when executing queries in ADO.
SAVE ME !!!!! SAVE ME!!!!
View 10 Replies
View Related
Apr 17, 2007
Hi,
Am attaching a db related to my question
I have 2 tables "Summary Table" and "Select1Summary"
"Summary Table" shows projects, departments and the available hours for each department
eg.
In "Summary Table" for 71043-40 Project, there are 1808 hours available at the beginning
"Select1Summary" shows Project, department, Month and the hours each department will be booking
eg.
In "Select1Summary" Table(Actually its a summary query, but am putting it as a table)
for 71043-40 Project, Department 11 on 30/04/2007 will be booking 171 hours (ie in April dept. 11 books 171 hours for project 71043-40)
for 71043-40 Project, Department 11 on 31/05/2007 will be booking 135 hours
for 71043-40 Project, Department 11 on 30/06/2007 will be booking 108 hours
What i need to show is running totals in a new query like
for 71043-40 Project , Department 11 on 30/04/2007 Available hours = 1637 (ie 1808-171)
for 71043-40 Project, Department 11 on 31/05/2007 Available hours = 1502 (ie 1637-135)
for 71043-40 Project, Department 11 on 30/06/2007 Available hours = 1394 (ie 1502-108)
Kind Regards,
Charley
View 3 Replies
View Related
Sep 26, 2007
I want to create a running or moving average of the most recent 5.
can anyone help here?
see attached file
Mix IDTest Date 7 Day1 Avg of 5Ave 28 Day
SF227
2/1/2007 3870
2/1/2007 2160 5415
2/7/2007 3580 5505
2/7/2007 3510 4955
2/12/2007 2990 32204965
2/19/2007 2800 30085500
2/19/2007 3330 32424920
View 2 Replies
View Related
Dec 4, 2007
Ahhhh this is doing my nugget in!!! I have a simple table with 4 fields
ID (unique number)
DATE (date)
CAPACITY (number of SKU we can hold)
ORDERS (number of SKU on order)
the data looks like this
ID DATE CAPACITY ORDERS
1 01/01/2007 250000 250000
2 02/01/2007 250000 300000
3 03/01/2007 250000 300000
4 04/01/2007 250000 300000
So looking at the above table we can see that we have more orders than capacity in our factory, however they require to see this in graph form, so what I need is for each ID a running total of the CAPACITY and ORDERS so over a given date range i would produce a graph to find the "pinch points" where we could see if the capacity is less than the orders we have over time.
so my new table would be:
ID DATE CAPACITY ORDERS CAPRUN ORDRUN
1 01/01/2007 250000 250000 250000 250000
2 02/01/2007 250000 300000 500000 550000
3 03/01/2007 250000 300000 750000 850000
4 04/01/2007 250000 300000 1000000 1150000
etc. which i would create my graph from. Ive looked at Dsum and some other methods but cant get my head around it so any help will be much appreciated.
Thanks Steve.
View 14 Replies
View Related
Jan 7, 2008
Hi
I have a query that shows part numbers with a total qty ordered for a specified time period. This first part of the query is fine and is made into a table.
I am then trying to use this table to create a running sum with the list sorted in descending order, and ultimately break the list where the sum reaches 80% of the total qty across the whole list. I have tried the following formula and the table has been indexed in the descending order it would need to be in. The IndexAlias has also been created and made into a fixed table prior to running the 'Running Sum' query.
RunTot: DSum("qty_ordered","Core Stock","[Index]<=" & [IndexAlias] & "")
I have taken this formula from the microsoft link below, (Method 2), and adapted it to my query. However, although I have a decent understanding of Access I do not understand the '&' in this formula. Removing this and the double quotes on the end returns an error and leaving them in returns zeros all the way down the 'RunTot' field. If anyone can help I would appreciate it as I am stuck on this.
http://support.microsoft.com/kb/290136
many thanks
:)
View 14 Replies
View Related
Feb 22, 2008
I have a table GIS_Subs with following fields:
Force_No ( Foreign Key)
Subs_Dt
Block Yr
Subs_Amt (number)
Running_Total
I wish to update Running Total for each record based on previous pay sorted in Ascending.
I am able to make a running sum but then it clubs all PersonNo of same date like:
[COLOR="Blue"]SELECT GIS_Subs.Force_No AS FN, DatePart("yyyy",GIS_Subs!Subs_Dt) AS AYear, DatePart("m",GIS_Subs!Subs_Dt) AS AMonth, DSum("Subs_Amt","GIS_Subs","DatePart('m', [Subs_Dt])<=" & [AMonth] & " And DatePart('yyyy', [Subs_Dt])<=" & [AYear] & "") AS RunTot
FROM GIS_Subs
GROUP BY GIS_Subs.Force_No, DatePart("yyyy",GIS_Subs!Subs_Dt), DatePart("m",GIS_Subs!Subs_Dt)
ORDER BY DatePart("yyyy",GIS_Subs!Subs_Dt), DatePart("m",GIS_Subs!Subs_Dt);COLOR]
How can I calculate it for each Person seperately?:rolleyes:
View 3 Replies
View Related
Apr 13, 2005
I have a number of forms and on each form there are a number of check boxes. I want to be able to add up how many check boxes read true. i.e if check1 = true then total = 1, if check2 = true then total now = two. Can I achive this?
View 3 Replies
View Related
Apr 15, 2005
Can someone test this for me?
I have created a tiny sub that increments a value on the form.
Each time the button is clicked the underlying sub runs twice causing the counter to add 2 instead of 1.
Note: I have not used the standard On_Click sub I've made my own.
Thanks
View 6 Replies
View Related
May 4, 2006
Hi to all. I think the subject besr describes what I want to do.
I need something similar to what I can do in a report (create an unbound text box and then assign to it the value =1 and go to the running sum property)
I think that it should be done easily or am I wrong?
Kyriakos
View 1 Replies
View Related
Dec 27, 2004
Hi
I'm trying to create a database to keep track of invoices .
on work that was done.is there any sample database that I could take a look at.Or can anyone help me on this I'm trying to capture price on parts + price on labor = total the order form in the tradewinds database looks good but don't know where the code is for calulations? can anyone help me out?
Thanks
Tom
View 9 Replies
View Related
Mar 28, 2006
Im having a problem doing a running total on my form.
I want the result to be displayed in a text box, with the figures being collected from a column of figures.
Any help is appreciated
View 2 Replies
View Related