Form / Query / Macro / Cmd Btn Problem

slrphd

Registered User.
Local time
Today, 11:14
Joined
Jan 6, 2004
Messages
91
My database contains information on many different power plants. I have created a form to retrieve data about a specific plant but there is more information than I can get onto a single page. So I added a command button to the form to retrieve a subset of data using a query. Clicking the command button is supposed run a macro that activates a query with the plant ID number as a condition to recall the specific subset. The query works fine by itself (if I enter the plant ID manually as parameter). When I click on the command button, nothing happens - I do not even get an error message to suggest where to start looking. Anybody have any suggestions? Thanks.
 
Look at the attachment - It may help you. (may being the key word)

John D
 

Attachments

Re: ExamplePlantDB

John,
Thanks for responding. I guess I must be dense but don't I need some information to re-create the workgroup file? When I try to open the *.mdb file, I am prompted to join one. Also the attachment to your response indicated two views and I do not know what that means in that context. I have been working as a solo on this project so everything I do is ad hoc. That means there are huge gaps in my mental database. Thanks, again for trying to help.
Steven
 
SC,
Thanks but please understand that, for me, a superuser only describes a couple of ex-wives so we'll need to go slow. Alternatively, this has the potential of becoming a great learning experience for me. The code your requested is:


Private Sub All_Fuel_Types_Click()
On Error GoTo Err_All_Fuel_Types_Click

Dim stDocName As String

stDocName = "qryComp Synopsis"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_All_Fuel_Types_Click:
Exit Sub

Err_All_Fuel_Types_Click:
MsgBox Err.Description
Resume Exit_All_Fuel_Types_Click

End Sub

Even in my advanced state of ignorance, I can tell that the code has no provision for acquiring the plant ID. And you can tell that I am still using the set-up wizards, which all the heavy weights in this forum seem to abhor. So, how do I inject the information I need? Thanks.
 
Steven,
What your trying to accomplish is probably out of my reach as I am learning as well. Next to the example (2 views) is just the amount of people who have viewed the attachment. As for it asking you to join or re-create the work group is beyond me. Its A97, so that may be the problem.

Either way, the example I posted is simple in the sense that you can place a text field (unbound) anywhere on your existing form. Set a command button next to this box that executes the Query.

Place this in the criteria of your query:
[Forms]![YourForm]![Yourtxtbox]

Im terrible at explaining things, but this would allow you to pull the query that you wish to view with a specific criteria (Power Plant #) by your command button as it references what you specify in the unbound box.

Hopefully that helps as it exhausts my knowledge in what your trying to achieve. If it doesnt help, hopefully someone else will chime in.

John D
 
Last edited:

Users who are viewing this thread

Back
Top Bottom