Solved

Command Button to run query and refresh subform isnt working:

Posted on 2008-06-23
6
1,471 Views
Last Modified: 2010-04-21
Command Button to run query and refresh subform isnt working:

I have two forms (they are essentially the same, just sized differently for different size computer screens):
Frm_Value_Request_Archive
Frm_Value Request_Archive1

The subform on each of these forms is the same:
SF_Value_Request_Arvhice

When I click on the RnRfrshQry command button in the second example below, I get this error message:
Enter Parameter Value: Forms!frm_Value_Request_Archive!Text24

The command button for frm_Value_Request_Archive DOES WORK:
Frm_Value_Request_Archive

Private Sub cmd_refresh_Click()
On Error GoTo Err_cmd_refresh_Click

    Dim stDocName As String

    stDocName = "qry_update_Value_Request_Archive"
    DoCmd.SetWarnings False
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    [frm_Value_Request_Archive subform].Form.Requery
DoCmd.SetWarnings True
Exit_cmd_refresh_Click:
    Exit Sub

Err_cmd_refresh_Click:
    MsgBox Err.Description
    Resume Exit_cmd_refresh_Click
   
End Sub


For this form (Value_Request_Archive1) the command button DOESNT work:

Private Sub RnRfrshQry_Click()
On Error GoTo Err_RnRfrshQry_Click

    Dim stDocName As String

    stDocName = "qry_update_Value_Request_Archive"
    DoCmd.SetWarnings False
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    [frm_Value_Request_Archive1 subform].Form.Requery
DoCmd.SetWarnings True
Exit_RnRfrshQry_Click:
    Exit Sub

Err_RnRfrshQry_Click:
    MsgBox Err.Description
    Resume Exit_RnRfrshQry_Click
   
End Sub
0
Comment
Question by:schneider_ks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
mrnev earned 500 total points
ID: 21846074
Does the Query_update_Value_request_archive query pick up the value from  Forms!frm_Value_Request_Archive!Text24?  If it does then this will only work when form  frm_Value_Request_Archive is open, not when form  frm_Value_Request_Archive1 is open.  One way around this would be to duplicate the query under a new name (say Query_update_Value_request_archive1 and make this pick up the parameter value from Forms!frm_Value_Request_Archive1!Text24 (note the 1 in the form name) and change the VBA on the button on frm_Value_Request_Archive1 to run the new query.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 21846082
open Value_Request_Archive1 in design view
select the outer part of the subform
hit F4 to open the property sheet
select the Data tab
  * see what is in the Source Object
 
  copy and post  here

select the Other tab
  * see what is in the Name

  copy and post  here


0
 

Author Comment

by:schneider_ks
ID: 21846121
The Source Object is the same for both forms:
SF_Value_Request_Archive
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:schneider_ks
ID: 21846154
Sorry, I misspelled the SF in the text of my original request - it should read
"The subform on each of these forms is the same:
SF_Value_Request_Archive"
0
 

Author Closing Comment

by:schneider_ks
ID: 31469724
Thank you so much - I'm working with queries that I didn't design - it's pretty simple, but I didn't think of this!  
0
 
LVL 4

Expert Comment

by:mrnev
ID: 21846204
<Thank you so much - I'm working with queries that I didn't design - it's pretty simple, but I didn't think of this! >

No problem, glad I could help.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question