DoCmd.OpenQuery problems

jerry28ph

jerry
Local time
Today, 12:57
Joined
Nov 16, 2008
Messages
141
Hi all,

how can I control the showing up of query value after I click my command button, I supposed to get only the value of my query to be store in my sub form "Smdr Qry_Total_Direct subform1", but using the DoCmd.OpenQuery I cant stop showing the window for the query details. Do I need to rephrase the DoCmd, Please need your help.

I just want to see the value of my query on my subform, I dont want to see the details of my query.


On Error GoTo Err_RnRfrshQry_Click
Dim stDocName As String

stDocName = "Smdr Qry_Total_Direct"
DoCmd.SetWarnings False

DoCmd.OpenQuery stDocName, acNormal, acReadOnly
[Smdr Qry_Total_Direct Subform1].Form.Requery

DoCmd.SetWarnings True
Exit_RnRfrshQry_Click:
Exit Sub

Err_RnRfrshQry_Click:
MsgBox Err.Description
Resume Exit_RnRfrshQry_Click

************

Thank you and more power to all.

Regards,
Jerry
 
It sounds like "Smdr Qry_Total_Direct" is a simple select query. Why do you wish to run it from a button?
 
i have other values on my main form that came from my subform, I want it to view them in my main form so that I could save them in one table for my report. please bear with my question i know sometimes its kind a confusing for you and the others, Im just starting to work with access and sql, and didn't the restriction of access when it comes to defining and asking question.
Do you have an idea, how can I save my query values to table directly, so that when I want to get my report, i can easily pull it out from my table?
Im open to any kind of suggestions if you have one.

Thank you so much.
Regards,
Jerry




It sounds like "Smdr Qry_Total_Direct" is a simple select query. Why do you wish to run it from a button?
 
If you simply wish to view the values collected by your query, set it as the control source of a form and open that form.

If however you wish to save the results of your query into a table, then what you need to do is convert your select query to an append query. Then when you run your query (using the above cove) the values will simply be appended to the table you nominate, you will not see the query at all.
 
Thanks for your help, i really appreciated. I try to do it, and search for any similar code on the net.

More power.

Regards,
Jerry



If you simply wish to view the values collected by your query, set it as the control source of a form and open that form.

If however you wish to save the results of your query into a table, then what you need to do is convert your select query to an append query. Then when you run your query (using the above cove) the values will simply be appended to the table you nominate, you will not see the query at all.
 
hi john,

for now i would use to view the values of my collected query, i had my subform on my main form, i use this to get the value of my query, is it normal to show the details in data grid of my query on another window? How can I avoid not to show this, since i can see the value of my subform on my main form.

Please advise.
Thanks




If you simply wish to view the values collected by your query, set it as the control source of a form and open that form.

If however you wish to save the results of your query into a table, then what you need to do is convert your select query to an append query. Then when you run your query (using the above cove) the values will simply be appended to the table you nominate, you will not see the query at all.
 
What I would do is to create a new form and use your query as the Control Source for that form. Whether you set it up to display the data as Datasheet or Continuous Form or single form view will depend largely on your personal preference and the number of records that the query will typically return.

Then in the OnClick event of your button use;

Code:
DoCmd.OpenForm "FRM_YourNewFormName", , , stLinkCriteria, acFormReadOnly
 
Thank so much. Appreciated.
More power JOHN...

Regards,
Jerry



What I would do is to create a new form and use your query as the Control Source for that form. Whether you set it up to display the data as Datasheet or Continuous Form or single form view will depend largely on your personal preference and the number of records that the query will typically return.

Then in the OnClick event of your button use;

Code:
DoCmd.OpenForm "FRM_YourNewFormName", , , stLinkCriteria, acFormReadOnly
 

Users who are viewing this thread

Back
Top Bottom