• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1477
  • Last Modified:

Command Button to run query and refresh subform isnt working:

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
schneider_ks
Asked:
schneider_ks
  • 3
  • 2
1 Solution
 
mrnevCommented:
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
 
Rey Obrero (Capricorn1)Commented:
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
 
schneider_ksAuthor Commented:
The Source Object is the same for both forms:
SF_Value_Request_Archive
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
schneider_ksAuthor Commented:
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
 
schneider_ksAuthor Commented:
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
 
mrnevCommented:
<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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now