PDA

View Full Version : Solved: OpenRecord?



zdunham
09-18-2008, 07:02 AM
Hi, I just signed up for the forums now, looks like a good place.

I'm currently making a button that opens a report based on user input of a process ID.



Dim inputString As String
inputString = InputBox("Enter ProcessID: ")
DoCmd.OpenReport "Process", , , "ProcessID = '" & inputString & "'"

Everytime I do this it just prints it from the printer instead of opening it in a dialogue or normal window. I've tried acViewNormal and acWindowNormal and it still just prints out. Is it supposed to do this? If so how do I get it to just open in a pop up or normal window?

I just realized I named the topic OpenRecord it should be OpenReport sorry.

CreganTur
09-18-2008, 07:28 AM
Welcome to the forums! It's always good to have new members.

Instead of using the OpenReport method, have you considered basing your report on a parameter query? This would provide the same results, just without the VBA.:sleuth:

zdunham
09-18-2008, 07:33 AM
Welcome to the forums! It's always good to have new members.

Instead of using the OpenReport method, have you considered basing your report on a parameter query? This would provide the same results, just without the VBA.:sleuth:

How would I do that?

CreganTur
09-18-2008, 07:40 AM
How would I do that?

Take a look at this article (http://www.fontstuff.com/access/acctut01.htm). It takes you through all the steps of creating and using parameter queries.

Then once your parameter query is working you will use this new parameter query as the record source for your report.

zdunham
09-18-2008, 07:49 AM
Ok well I see how parameter queries would work but it doesn't say how to create a new parameter query, all of the property boxes shown there I have never seen. Sorry if that is newbish but I'm used to SQL server and I don't know Access well.

Not sure if this helps at all but that code I showed at the top was in a button click method. Its a button on my main form to browse the record of the entered process ID. On the main form there is a box where you can enter process ID and then it auto-fills so the data-enterer may need to look up a process.

CreganTur
09-18-2008, 08:06 AM
but it doesn't say how to create a new parameter query


Instead of typing a value or expression into the criteria cell, type some text enclosed in square brackets ([ ]).
The text you type will appear as a prompt on a dialog box, so you might want it to be in the form of a question to the user.

So in your query for the ProcessID field you would put something like '[Enter a Process ID]' in the criteria row for that field (in query design view). When you run the query an input box will appear, the text of which says "Enter a Process ID". Wheveter text your User puts into the inputbox is what will be used for the criteria.

zdunham
09-18-2008, 08:18 AM
So in your query for the ProcessID field you would put something like '[Enter a Process ID]' in the criteria row for that field (in query design view). When you run the query an input box will appear, the text of which says "Enter a Process ID". Wheveter text your User puts into the inputbox is what will be used for the criteria.

Alright, I don't have any query is what I'm trying to say, I can't get to the place in the picture where the criteria box is shown. I have a process subform where you can enter multiple processes for the current system, next to the subform I have a button to look up processes. The code I showed happens on click of that button, I'm going to make it so if the user doesn't enter a process ID it shows all processes. Then they find the one they want, enter the process ID in the subform and it will auto fill, this is how my boss wants it. So as far as I know I don't have a process ID query. I'm just trying to open the report for processes, I already created the report and it works fine. When I click the button with the current VBA code it prints the right report I just don't want it to print, just pop up.

zdunham
09-18-2008, 08:33 AM
Thanks for your help I figured it out, it needed acViewPreview to open in a preview window. Thanks though!

CreganTur
09-18-2008, 08:43 AM
Thanks for your help I figured it out, it needed acViewPreview to open in a preview window. Thanks though!

I completely misread your first post :doh:

Yes, acViewPreview is what you want.


Also, for future reference, to get to what the pictures were showing you would be using what is called Query Design view. It's Access's graphical way to create queries.

On the database window you would click on the Queries object. Then you would either create a new query in design view, or open an existing query in design view.

If you every want to look at the SQL of a query, then you can select what is called SQL view- it brings up a code window for SQL. If you want to code in a query by hand using only SQL you would create a new query using design view, but when the tables winodw appears you would close it without selecting any of them. When you do this, the view button will change so that it shows "SQL"- clicking this takes you to the same SQL code window.