Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Move Control From Sub To Main
Dg Ewing 
     
4 years ago
how can I execute my refresh btn from my subform before updating the main form to the person selected in the subform. the pic hopefully illustrates my question more clearly
Dg Ewing OP  @Reply  
     
4 years ago

Adam Schwanz  @Reply  
           
4 years ago
Value From a Form might help.

Just add to the event in the subform to refresh before opening the form.
Dg Ewing OP  @Reply  
     
4 years ago
Thanks Adam, I have tried to add the event in the subform to refresh, and because the the subform uses a different table than the main form, it is not so initiative
this is the subform code:

Private Sub perid_Click()
    Dim passValue As String  
    
    passValue = Me!PerID
    Forms!MDKA_Form!.Requery ' this does not work
    
   ' MsgBox passValue
    DoCmd.OpenForm "MDKA_Form", , , "PerID=" & passValue
    
End Sub
Adam Schwanz  @Reply  
           
4 years ago
Forms!MDKA_Form.Requery Not second !
Dg Ewing OP  @Reply  
     
4 years ago
this is the main form refresh:

Private Sub cmdRefresh_Click()
    Dim strsearch As String
    Dim passValue As Long
    passValue = PerID
    Me.FilterOn = False

    strsearch = "SELECT * from EwingIndex_Master"
    Me.RecordSource = strsearch
    DoCmd.GoToControl "PerID"
    DoCmd.FindRecord passValue
End Sub
Adam Schwanz  @Reply  
           
4 years ago
Actually might be Forms!MDKA_Form.Form.Requery
Dg Ewing OP  @Reply  
     
4 years ago
Adam, I do now what you mean "Not second! "
Adam Schwanz  @Reply  
           
4 years ago
Forms!MDKA_Form!.Requery ' this does not work

Your code says this, see how after FormsMDKA_Form you have !.Requery

You don't need that second exclamation mark there, just a dot. Try out that code above Forms!MDKA_Form.Form.Requery
Dg Ewing OP  @Reply  
     
4 years ago
and I just figured out what not second....do not use the 2nd ! use only one !

got it

and I put both

Forms!MDKA_Form.Form.Requery
Forms!MDKA_Form.Requery

and it works....thanks
Dg Ewing OP  @Reply  
     
4 years ago
Well , it almost works,  it works for the next click, but the next one goes to a blank record....damn...almost had it
Dg Ewing OP  @Reply  
     
4 years ago
and how do put the white background on the code?
Dg Ewing OP  @Reply  
     
4 years ago
How can I shift the active (focused) form from subf to main.
Adam Schwanz  @Reply  
           
4 years ago
Thats an admin HTML thing. I don't think you can do it.

So looking over your code, you have it over complicated.

Private Sub perid_Click()
    Dim passValue As String  
    
    passValue = Me!PerID
    Forms!MDKA_Form!.Requery ' this does not work
    
   ' MsgBox passValue
    DoCmd.OpenForm "MDKA_Form", , , "PerID=" & passValue
    
End Sub


Why bother declaring a variable, setting the variable, then using the variable for the open form? Why not take out all the variable stuff and just do

Private Sub perid_Click()
    Forms!MDKA_Form!.Requery ' this does not work  
   ' MsgBox passValue
    DoCmd.OpenForm "MDKA_Form", , , "PerID=" & [PerID]
End Sub
Adam Schwanz  @Reply  
           
4 years ago
Same thing here

Private Sub cmdRefresh_Click()
    Dim strsearch As String
    Dim passValue As Long
    passValue = PerID
    Me.FilterOn = False

    strsearch = "SELECT * from EwingIndex_Master"
    Me.RecordSource = strsearch
    DoCmd.GoToControl "PerID"
    DoCmd.FindRecord passValue
End Sub


to

Private Sub cmdRefresh_Click()
    Me.FilterOn = False
    Me.RecordSource = "SELECT * from EwingIndex_Master"
    DoCmd.GoToControl "PerID"
    DoCmd.FindRecord PerID
End Sub
Adam Schwanz  @Reply  
           
4 years ago
If you want to move focus from the subform to the main form do Forms!FormName!FieldName.SetFocus
Adam Schwanz  @Reply  
           
4 years ago
So you are typing in a search in the top form, and that is changing the records shown in the subform, then when you push to open it in the subform you want the main form to go to that record is that correct?
Adam Schwanz  @Reply  
           
4 years ago
You can probably do like a open event in the subform like

Forms!MDKA_form.Form.Recordsource = "Select * From [EwingIndex_Master] where PerID=" & PerID
Dg Ewing OP  @Reply  
     
4 years ago
no it is not working,  need to refresh/requery the main form source
Dg Ewing OP  @Reply  
     
4 years ago
yes your:

Forms!MDKA_form.Form.Recordsource = "Select * From [EwingIndex_Master] where PerID=" & PerID

works and it is a lot cleaner  THANK YOU!!
Adam Schwanz  @Reply  
           
4 years ago
Glad to hear, problem solved then? ;)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/1/2026 8:11:45 PM. PLT: 0s