?
Solved

Return to Subform after ActiveX Control Loads

Posted on 2012-04-03
13
Medium Priority
?
619 Views
Last Modified: 2012-05-07
I have code in the On Current event of a subform that loads a pdf associated with that record into an ActiveX control on the Main form.  The problem is that the focus moves from the subform to the ActiveX control and I can't get it back to the subform without clicking on that record again.  How can I either return to the record on the subform or never leave it in the first place?  Here's what I'm using (feel free to recommend a different method):

Private Sub Form_Current()

'Load Incorrect File
Dim sIncorrectScan_Path As String
sIncorrectScan_Path = "Q:\A_DPW\Images\SewerTieCards\" & [Address] & ".pdf"

Forms!DocumentManagementQC!AcroPDF7_Incorrect.LoadFile (sIncorrectScan_Path)
Forms!DocumentManagementQC!AcroPDF7_Incorrect.setShowToolbar (True)
Forms!DocumentManagementQC!AcroPDF7_Incorrect.setView ("Stretch")

End Sub

Open in new window



Thanks,
Jeff
0
Comment
Question by:wellesleydpw
[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
  • 6
  • 5
13 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 37801409
Have you tried adding a setfocus at the end?

me.sometextboxname.Setfocus
0
 

Author Comment

by:wellesleydpw
ID: 37801418
I tried that and also tried including a 2 second pause but neither worked.  Focus was still on the PDF.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37801577
Try using the webbrowser control instead...

Private Sub Form_Current()

'Load Incorrect File
Dim sIncorrectScan_Path As String
sIncorrectScan_Path = "Q:\A_DPW\Images\SewerTieCards\" & [Address] & ".pdf"
Me.WebBrowser7.Navigate url:=sIncorrectScan_Path

End Sub
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:wellesleydpw
ID: 37801670
Tried the WebBroswer control and it's behaving the same way.  My subform is on a tab control - would that affect it?
0
 

Author Comment

by:wellesleydpw
ID: 37801750
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37802086
It is not clear from your pdf  were your "subform" is...
I see a "Tab Control" though....

It is also not clear what you mean by:
<The problem is that the focus moves from the subform to the ActiveX control and I can't get it back to the subform without clicking on that record again. >

I put a msgbox on the Got Focus event of the Webrowser control and it IS NOT receiving the focus...
(Please try this yourself to verify)
But if you want to set the focus back to another control, simply use code to so so:
Me.SomeControl.SetFocus
Or
Forms!SomeForm!SomeControl.setFocus.


...else, just post a simply sample of this form and state clearly what you want to happen and when...
0
 

Author Comment

by:wellesleydpw
ID: 37802341
Thanks boag2000,
The subform is the datasheet on the tab control.

I'll try to be clear about the behavior:
The pdf loads in the on current event on the subform.  If I then press the down arrow, the pdf scrolls down (this is why I think the PDF has the focus).  

I tried your recommendation of putting a msgbox in the Got focus event.  The msgbox does appear right BEFORE the PDF loads.

I continue to try your recommendations.
Jeff
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37802414
<The subform is the datasheet on the tab control.>
Still confused, ... you cannot inset a subform into a form in Datasheet view.

How about  you just post a example of this DB...?

My test was using the webbrowser control and it did not get the focus....
0
 

Author Comment

by:wellesleydpw
ID: 37815994
Sorry for the delay I was at a conference the last two days.

I've posted an example of the form (you'll need 2 pdfs in C:\ named "1 Main Street" and "2 Main Street") for the webviewer to display them.

I've placed a msgbox in the got focus event of the  one field on the subform.

Thanks.
Jeff
DB.accdb
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 2000 total points
ID: 37826279
<I can't get it back to the subform without clicking on that record again.  How can I either return to the record on the subform or never leave it in the first place?>
What the need to move the focus back to the subform?

Besides your code *does* move the focus back to the subform control.

If you comment out your line:
    Forms!Addresses!Addresses_sf_Index!Address.SetFocus
Then close, ...then reopen the form, you will see that the focus is not in the subform control.

Then when you un-commented the line, then close, then re-open the form, ...you will see that the focus moves to (and highlights) the subform control.
(now the subform *control* has the focus)
0
 

Author Comment

by:wellesleydpw
ID: 37914686
I've requested that this question be deleted for the following reason:

No good solution.<br /><br />Thank you.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37914687
Solution and explanation posted in 37826279
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

765 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