Modules & VBA :: Passing Parameters To Report Doesn't Work

Feb 23, 2015

I have a query that sums up the number of parts used. This works fine.

I want to be able to limit this query to parts used after a specific date.

I have in my report

DoCmd.OpenReport "Part Totals Report", acViewPreview, , "[Part Date])>= " & SQLDate

The report is bound to a query that has 2 group by fields, 1 count field a a further field, a date field ([Part Date], that I put a default criteria on. This field is not displayed. If I don't put a criteria on this field disappears when I close and open again.

I pass a date to the program via a form and this ultimately ends up in SQLDate. When I run this I get promted to enter [Part Date] even though I'm setting it equal to SQLDate above. I can out garbage to a proper date in here either way the report picks up the default date entered in by the query.

1. Get rid of all of the parameters off the query.

2. Then you can use the Where Clause of the DoCmd.OpenReport code to specify the parameters based on your variables.

1.Not sure what this means but when I get rid of the criteria for the parameter the field disappears (I'm setting the show field to no as I don't want totals group by date). Getting rid of the field gives me all parts used.

2.I think I'm doing this in the above but will bow to superior knowledge!!

or is it I can't pass a parameter to a report run by a query that is grouping fields together to produce a count.

Incidentally once the report has been run (albeit with the wrong parameters) and I go into design mode and look at the property sheet for the report the correct filter is there (i.e., the date that has been input) but it quite clearly ignores this.

View Replies


ADVERTISEMENT

Multiple Parameters Doesn't Work On Multiple Fields

Jun 27, 2006

I created the below query to come up with a new form. When I enter a single parameter, it works fine. When I modify the code and enter multiple patameters, it also works fine if I do not enter any information for the parameters. But once I enter one of the parameters information, then it does not come up with anything. I double checked and made sure it was typed in correctly. Is there a trick when entering multiple parameters on a query?


SELECT [JE 06 Log].[Operational Region Name], [JE 06 Log].[Period Name], [JE 06 Log].[Source System], [JE 06 Log].[Source Name], [JE 06 Log].[Category Name], [JE 06 Log].[Associated Category Name], [JE 06 Log].[JE Name], [JE 06 Log].[JE Base #], [JE 06 Log].Area, [JE 06 Log].[Line Description], [JE 06 Log].[Natural Account], [JE 06 Log].Description, [JE 06 Log].[JE Entry Date], [JE 06 Log].[Debit Amount], [JE 06 Log].[Credit Amount], [JE 06 Log].Amount
FROM [JE 06 Log]
WHERE ((([JE 06 Log].[Period Name])=[Enter Period]) AND (([JE 06 Log].[Source Name])=[Enter Path]) AND (([JE 06 Log].[JE Base #])=[Enter Base Number]) AND (([JE 06 Log].[Natural Account])=[Enter Natural Accnt])) OR ((([Enter Period]) Is Null) AND (([Enter Path]) Is Null) AND (([Enter Base Number]) Is Null) AND (([Enter Natural Accnt]) Is Null));

View 6 Replies View Related

Passing Parameters To A Query From A Form To Filter A Report

Aug 15, 2006

I would like to have a user enter a start date and an end date into two
textboxes on a form. The two dates will be used to query a table. I
would then like to print a report that was created from that query.

Here is the query created as a stored procedure:


SELECT Transactions.*, Hoods.*
FROM Hoods INNER JOIN Transactions ON
[Hoods].[ID]=[Transactions].[BoxID]
WHERE ([Transactions].[Date] Between [@StartDate] And [@EndDate])
ORDER BY [Transactions].[Date];


What would be the best way to pass txtStartDate to @StartDate and
txtEndDate to @EndDate in the VBA code of the form? How would I open or
print the report created from that query filtered on that date range?


Any suggestions? Am I going about it wrong? Should I have created the
report from the above query, or should I do it another way? Can anyone
direct me to some code that does all of the above or something
similiar?


Thanks.

View 14 Replies View Related

Reports :: Navigation Form - Passing Query Parameters To A Report

Aug 4, 2014

I have a navigation form that will have 6-8 tabs. We were using about that many databases, but we are finally consolidating them into one. The result of us using so many databases has been the multitude of forms and reports that were necessary for each database prior to merging them together.

The problem: There will be anywhere from 12-20 (text boxes) that the user can use to search anything in our database. What we need to have happen, if possible, is for those search parameters to show up in the header of our report if they have text in them. If the text box is blank, it should not show up in the header of the report.

I have read how to to do the start/end date technique, but I do not know if that would work for what we are doing since the boxes would only show up if they are populated by the user.

View 4 Replies View Related

Reports :: Criteria Doesn't Work In Chart Report

Oct 27, 2013

I have a query that has a field that reads DateReceived By Month: Format$([Workorders].[DateReceived],'mmmm yyyy') The criteria line is Like "*" & [Enter Month & Year (Leave Blank for all)] & "*" And this works when I run the query. If I enter october 2013 it shows only records for this date range like it should.

Then I built a bar chart report that will show the workorders only for the month entered. The problem is, If I leave this field in my query the chart does not update . When I open the chart it will prompt for the month and year but the data in the bar chart doesnt change. If I remove this field the chart updates as expected.

If I go into design view for the report and then right click on the chart and go to properties , then to row source, it reads as this:

TRANSFORM Sum([Workorders Query2].MyTime) AS SumOfMyTime SELECT [Workorders Query2].SerialNumber FROM [Workorders Query2] GROUP BY [Workorders Query2].SerialNumber PIVOT [Workorders Query2].[MXDPrinter];

If I click on the elipstical to go into query tools for this line , and click on run I get the error : The microsoft Access database engine does not recognize '[Enter Month & Year (Leave Blank for All)]' as a valid field name or expression.

So my criteria runs normally in the query and returns the correct records, but I can't get it to work in the chart .

View 1 Replies View Related

Modules & VBA :: Why Does Emailing A PDF Work But Saving A PDF Doesn't

Jul 24, 2013

I'm trying to figure out why I can email a report as a PDF, but not save it as a PDF using the code below? When I save, I get the dreaded error 2501.

The searching I did for this said to uninstall and reinstall printers (I've done that - seems to have no effect), or took issue with filtering the report with a where clause (but if that was an issue, why does it email a PDF just fine?).I'd just like to be able to save a report as a PDF to a specified location.

CB
Developing in: Access 2010; Win7
For use in a mixed 2007/2010 XP/7 environment

Code:

Private Sub EmailDietCardBtn_Click()
On Error GoTo MyErrorHandler
Me.Refresh
Dim stReport As String
Dim stWhere As String
Dim stSubject As String
Dim stEmailMessage As String
Dim stCaption As String
Dim myPath As String

[code]...

View 11 Replies View Related

Modules & VBA :: Switchboard Form Doesn't Work

May 27, 2014

I have developed a project in Access 2003 and it works absolutely fine. There is a switchboard form too and that works fine as well. But now in our company we are moving all the projects developed in 2003 to 2010. And so I have noticed the switchboard form doesn't work in Access 2010 the way it works in 2003. The Switchboard form doesn't display all the options in 2010.

View 5 Replies View Related

Modules & VBA :: Repaint Doesn't Work Until End Of Code

Jul 31, 2015

I have a process which runs lots of slow append queries, so I want to reassure the user of progress, by changing the font colour of labels to green when the relevant queries have finished. This is the code I'm using

Code:
'Update the older data if that option is selected
If Me.Menu_YearOption.Value = 1 Then
DoCmd.OpenQuery "2-10 Append FY1112"
Me.lbl1112.ForeColor = 32768
Me.Repaint
DoCmd.OpenQuery "2-12 Append FY1213"

[Code]...

Each query takes about a minute to run, as it gets data from a sharepoint server, but the labels don't turn green one at a time as expected. Instead, I get the spinning wheel until all the queries have run, then all the labels turn green together.

Is there something else I should be doing rather than Me.Repaint ?

View 11 Replies View Related

Modules & VBA :: Query To Search For Records - Passing Parameters In A QueryDef

Aug 27, 2013

I have a query that searches for records that are between two dates using the WHERE clause. The two dates are referenced to two respective text boxes on a form. On the same form I have a button that will launch the query in VBA using querydefs. I get the error 3061 saying I need to input the parameters. Therefore I am a bit unsure how to set the parameters in VBA. So far I have done this:

Code:

Dim Db As DAO.Database
Set Db = CurrentDb
Dim QDef As DAO.QueryDef
Dim rst As DAO.Recordset
Set QDef = Db.QueryDefs("Rqt_F_BrokerageMandate_MF3_TEST")

[Code] ....

Where Date_VL is the field to be filtered. I know this is wrong but all examples I have seen have equated the parameter to a fixed value i.e 30/12/2012 for example, but I want this to be at the users discression. The only way I know of to get around this at the moment would be to write a temp query in VBA with PARAMETERS in the SQL code instead using the method above/

After this I'm going to assign the recordset to a matrix but that's a different story!

View 10 Replies View Related

Modules & VBA :: Application Quit Doesn't Work On Network Users

May 26, 2014

My database is used by a few users on a shared drive in "read-only" mode so they can't change any data.I set a scheduled task to copy an updated version of the database (which I edit) every morning.

The problem is that when the users forget to close the database file I can't overwrite it.For this purpose I wrote a small code that quits the application at 00:00 using Application.Quit.The code WORKS when I test it on my computer, but every morning when I try to open the file I see that it is opened by another user since I also open it as "read-only" - meaning the code didn't work...getting the code to work properly OR get a better solution to be able to overwrite the file even though it's opened by other users.

View 10 Replies View Related

SQL Server - Passing Parameters

Jun 15, 2005

Hi,

After years and years of working with Jet, I am now trying to use SQL Server backands and am having problems passing parameters to a stored procedure.

How can I build a query which where I can say "WHERE ([AField]=""" & Forms!BlarBlaretc.value & """)" as I can in access because as I understand it you can not look at front end information from the SQL backend.

Any help (and start at the beginning) would be much appreciated.

Cheers

Stu

View 1 Replies View Related

Passing Parameters To A Query

Feb 1, 2006

Guys I need your help/Advice...

In my Access Database I have a query (lets say qry1) and in this query i have 2 fields for start and end date, which is provided by 2 Get functions.

also i have qry2 based on qry1
then qry3 based on qry2
and finally qry4(using sql in code) based on qry3, and non of these 3 queries have the start and end date fields.

now here is the problem: I am trying to set the criteria in qry4 and then open a record set on this query(qry4) to use the data that it pulls out...


strsql = ""
strsql = "SELECT Sum AS AREA_TOTAL " _
& "FROM qry3 " _
& "WHERE ENERGY_AREA like '" & Area & "';"

Set MyDB = CurrentDb

Set rst = MyDB.OpenRecordset(strsql)



but when the last line is executed I get this error message:

Runtime Error '3061':
Too few parameters, expected 2.

i also tried doing this:

strsql = ""
strsql = "SELECT Sum AS AREA_TOTAL " _
& "FROM qry3 " _
& "WHERE ENERGY_AREA like '" & Area & "';"

Set MyDB = CurrentDb


MyDB.QueryDefs("qry4").sql = strsql

Set rst = MyDB.OpenRecordset("qry4")


but when the last line is executed it gives me an error message saying that the query does not exist or the name is not spelled correctly. (Ps. I have created the query and the criteria does update once the Select statement is run in the code!)

again the reason for this is that the query has not been populated as the main query (qry1) needs 'strat date' and 'end date'!

Is there anyway I can pass these 2 parameters to qry4 directly using code? If there is a way then this will definitly work as i tried opening the query manually in the Query window and after I input the 2 dates in the input box the query ran successfully!

I would appreciate any help/suggestion guys, I need to sort this out quickly as i have a deadline... Cheers

View 1 Replies View Related

Passing Parameters To A Form

Dec 22, 2006

Hi all,

I have a continuous form that is bound to a SQL Server view.

For each record in my form I have a button, which when pressed opens up a second form. The second form is bound to a stored procedure that takes a parameter. The parameter value that I want to pass to this second form is the value of one of the fields in the first form.

I did the following in the click event of the button on my first form:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SecondForm"

stLinkCriteria = "[Field1]=" & "'" & Me![Field1] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

However, when I run this it keeps prompting me to specify the value of Field1 so this value is obviously not getting through. Do you have any idea why this might be happening?

Thanks in advance
Kabir

View 4 Replies View Related

Passing Several Parameters To Subform

Dec 22, 2006

Hi,

I would like to transmit several parameters from my main form to the subform when I open it.

Parameters could be used in the subform by onload event, for eample, to define form caption, hide or show buttons, enable or disable edit boxes, give them a color, ... It could also allow to use the same form in different application contexts, which would reduce so the development time.

More than one technique might be possible.
I used the following one :
- I put the parameter value I want to pass into myParameter
- when click on the button to open the subform :
DoCmd.OpenForm myDocument, acNormal, , , , , myParameter
- when loading the subform, retreive the parameter value in Me.OpenArgs and using it (eg disable a button)

It works fine. But I can pass only a single value with this technique and it's not enough. I tried to give an array as myParameter and fill it with my parameters values, but Access refuses an array to be in the DoCmd statement for OpenArgs option.

Any idea about passing several parameters to the subform ?
Or may be an alternative to the DoCmd technique ?

Thanks.

View 5 Replies View Related

Passing Parameters From Form To Queries

Mar 23, 2006

Good Afternoon,

I am trying to create a form where a user will enter in a value into a text field. Afterwards, when the user clicks "Enter", a query will run and will LOOK FOR THE VALUE THAT WAS ENTERED INTO THE TEXT FIELD. i.e.
User enters their address into the field and clicks the enter button.
Afterwards, a query will run like
select * from customers where address = @address <== the value the user entered into the text field. This is where the mystery lies. How do you pass values?????

Thanks,
Nervous Jervous

View 6 Replies View Related

Why Doesn't This Work ?

Oct 5, 2006

i am trying to run an append query in SQL which appends a calculated value into another table 50 times incrementing the day by one day each time. When I run it it asks me for the parameter [NewDay] each time. It is obviuosly not picking up the variable.

Can anyone tell me why ?



Dim NewDate As Date
Dim n As Integer


For n = 0 To 50

NewDate = Date + n

DoCmd.RunSQL "INSERT INTO InventoryEvolution ( SAP, Stock, [Date] ) SELECT UK_Product_Estimate_Live.[RE SAP Code], ((Sum([Estimate01])+Sum([Estimate02]))/50)*-1 AS Stock, NewDate From UK_Product_Estimate_Live GROUP BY UK_Product_Estimate_Live.[RE SAP Code] HAVING (((UK_Product_Estimate_Live.[RE SAP Code])=513450))"

Next n

View 6 Replies View Related

Why It Doesn't Work?HELP!!

Sep 14, 2005

Hi all,
I get this error "You tried to execute a query that does not include the specified expression 'SITENAME' as part of an aggregate function."


The query is:

SELECT o1.name AS SITENAME, o1.vertical_loc/10000000 AS LAT, o1.horizontal_loc/10000000 AS LON, c.CELLGLID AS CELLID, 'traffic_total' AS Expr1, sum((MEBUSTCH_HR+MEBUSTCH_FR)*period_duration)/sum(period_duration) AS Traffic, 'traffic_hr' AS Expr2, sum(MEBUSTCH_HR*period_duration)/sum(period_duration) AS Traffic_HR
FROM objects AS o1, objects AS o2, c_bts AS c, p_generic_cell AS p
WHERE c.int_id = o2.int_id and
o2.parent_int_id = o1.int_id and
p.bts_int_id = o2.int_id
GROUP BY SITENAME, LAT, LON, CELLID, Expr1, Expr2;

I know the problem is with the group by clause. In MySQL it just works using "group by p.bts_int_id. I learnt in access i have to include all non-aggregated fields in the group by clause, and that's what I've done!! WHY!!Please help me!!!

View 3 Replies View Related

Why Doesn't Like Work

Mar 14, 2007

Hallo,

The following what I do not understand:


Set cmd = New ADODB.Command
Set cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText

cmd.CommandText = "SELECT par1 FROM tblparameters Where tblparameters.gcnf = 'XMLexp' AND ((tblparameters.ccnf) Like 'ExpTijd*')"
Set rec = cmd.Execute()

Do While rec.EOF = False
MsgBox rec("par1").Value
rec.MoveNext
Loop


I don't get any result back. If I changed it likt the following:
tblparameters.ccnf = 'ExpTijd1' , in the query, I get one record back.
So my conclusion the query is right but the Like doesn't work in these circumstances?

thanks in advance.

Nico

View 3 Replies View Related

Why Doesn't This Work?

Apr 14, 2005

hi folks,
I am designing an application for an assignment for college, all seems to be going ok except that I have to teach myself access from a book. When I update a record on a form and go to another page it works fine, but if I attempt the same action ( for example creating an appointment then moving to a new form to confirm they have arrived) a second time I am getting an error which tells me I can't save the record. I think it is to do with updating the recordset when the new form is opened. I have an update record button on the form (created by the wizard) but it wont update on the second attempt. Could someone please tell me the code to update a recordset on the formload procedure. Ive tried me.recordset.refresh and me.recordset.requery but I still can't solve the error. Please help I've got to hand this assignment in in 2 weeks. thanks in advance
Chris

View 4 Replies View Related

Modules & VBA :: Delay Report Opening Until Parameters Are Chosen

Dec 22, 2014

I have a command button (well, I have a few) that I would like to open a report, first opening a form that allows the user to enter a start and end date.

The code so far is:

On Error Resume Next
If Err = 2501 Then Err.Clear
DoCmd.OpenForm "DateSelect", acNormal
DoCmd.OpenReport "All Events Report", acPreview

Now, when run, this code opens the form (DateSelect), but the report starts to run immediately - the On No Data event of the report kicks in (message box along the lines of "No data, closing report", so before the user has the opportunity to enter the dates, the report has decided that there is no data an closes.

Is there a way to pause the opening of the report until after the OK button is clicked on the pop up form?

Just for the sake of clarity, the pop-up form DateSelect is used to open various reports, so I can't add the open report command to the code for the OK button (that I know of?)

View 8 Replies View Related

Passing Parameters From Excel To An Access Query

Jun 4, 2007

Hey folks,

Not sure if this is the best forum but decided to put it here anyway.

I have a Access query that reads:

SELECT bleh
FROM blah
WHERE something > 10

Then in Excel I pull the data across using:

Set qdf = db.QueryDefs(qryName)
Set rs = qdf.OpenRecordset

and paste the data using

ws1.Range("IV1").End(xlToLeft).Offset(0, 2).CopyFromRecordset rs

I now want to change the query so the where statement reads

WHERE something > [amt]

So the question is how do I pass the value for the parameter value for [amt] from excel to access?

View 1 Replies View Related

Why Doesn't This Work Anymore.

Jun 7, 2007

I'm trying to run an update query to trim a field to the first 8 characters.

I've used this in the past, but now it wont work. I'm stumped.

Left(Trim([IMIE_MSISDN_IMSI]![IMEI]),8)

Now when I try the records remain unchanged, i.e. 13 characters.

Any ideas?

View 2 Replies View Related

Copied MDW Doesn't Work

Jun 14, 2007

Hi! I'm relatively new to Access (2003) . I had to modify a shared network app so I copied it off and renamed it, made my mods and everything is fine. I then went to another app that connects to the original app to obtain data for display and synchronization, modified the call to open the new app including the new mdw. When it hits the new mdw, it can't open it because it says it's being used exclusively or the workgroup file is missing. It's not being used exclusively and it doesn't appear to be missing. The network path is correct. If I use the mdw from the original source app, it works fine. Please advise! :(

View 1 Replies View Related

My Database Doesn't Work Like Before?

Aug 22, 2007

Hello everbody,

I'm sorry if my thread is in wrong section, cause I'm first time on this great forum :(! I hope you'll undrestand me ;)

My problem is with my database for my coffee bar, man who made database is still, and I don't have somebody to repair my database unfourtanetly :(

I formatted my C:, cause I installed new OS Windows XP PR SP2, and everything is deleted, but I save this .mdb file, but I don't have instalation CD for this program, cause man who installed me this database didn't give me instalation file :(!

And I saved this .mdb file, and now I try to run this POS.mdb,I can open "POS KASA" in english POS CASH, and I see articles - (ARTIKLI), and value of them it account values of them, just program doesn't count for me like before "sume" or "total" of EX. one count, for example coca cola 2.5 KM, fanta 2.5 KM = 5 KM, and now he doesn't count sume - total in program total is "UKUPNO", if somebody to know to repair this, or something another what is importing to work this database like before, please help me, database is on bosnian, if you need translating just ask me, cause I don't know to edit this file, and to have access to change words :(!

1'st colone in program interface (bosnian - english)

Sifarnici -something like codes

Artikli = Articles
Ulazi = Inputs
Storno racuna = storno count
Pregled storno racuna = review storno count

2-nd colone in program interface

Dokumenti - Documents

POS kasa = POS cash register
Dnevni promet = daily exchange
Trenutni saldo kase = current saldo of cash register


3-rd colone in program interface
Reports

Printanje prometa po broju = Printing exchange by number
Printanje prometa od datuma do datuma = Printing exchange from date to date
Printanje trenutnog prometa = Printing current exchange

IZLAZ = EXIT :)


Actually for me the most important is POS CASH REGISTER, cause it doesn't count total value of one count , total = ukupno doesn't work, sume doesn't work, and I can't give on my guests count, and I have problem with inspection cause I don't have counts :(, please help me and if you can repair this; IN ADVANCE TNX MUCH!

Greetings to all, from Sarajevo, Bosnia and Herzegowina!

I'm sorry really on my bad english, and I hope you'll understand me :(!

View 1 Replies View Related

Queries :: IIF With Sum Doesn't Work

Jan 9, 2014

I need to do the price in table [price] multiply by 1.20 if the price is higher then 150. If the price is between 75 and 150 it have to multiply by 1.25. Continue... continue... continue...

expr1: IIF([Price]>"150",[Price]*1.20,IIF([Price]>75,"[Price]*1.25",IIF([Price]>50,"[Price]*1.28",IIF([Price]>30,"[Price]*1.35",IIF([Price]>15,"[Price]*1.45",IIF([Price]>0,"[Price]*1.6"))))))

View 3 Replies View Related

Bypass Startup Doesn't Work!

Jul 28, 2005

If I hold down the SHIFT-key and click on my access database the database boots up with the startup options! I can't get into my database even if I hold down the SHIFT key!! Help me, please

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved