Solved

Command Button to run query and refresh subform isnt working:

Posted on 2008-06-23
6
1,469 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
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

776 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