On Got Focus Issue

  • Thread starter Claudette Hennessy
  • Start date
C

Claudette Hennessy

I have a simple continuous form with a text field containing company names.
I would like information to appear when the user clicks on the field, and
disappear when the user clicks on another company. The following sub brings
up the query ok, but then I can't close the query.
My first thought was to have the query open for 5 seconds or so and then
close, but I can't figure out how to do this, either.

Private Sub txtShopname_GotFocus()
Dim stDocName As String

stDocName = "qryDealerHistory"
DoCmd.OpenQuery stDocName, acNormal, acEdit
???????
End Sub

Thanks in advance,
Claudette Hennessy
 
S

SteveM

Seems to me that this would be a good use of a subform, had you considered
that?

Steve
 
C

Claudette Hennessy

Yes, I know a form/subform could be used, but I want (the client wants) the
form (or company info) to appear only if a company is clicked. The form
should close if another company is clicked or if x time has gone by and
reopen with the new information. Whether I use a form or query, I don't
know how to close the object when the original focus is lost.
Claudette
 
S

SteveM

I suppose you could create a popup form (a form with the Popup property set
to Yes). You can use the popup form's OnTimer event to close the form after a
specified number of seconds (Timer Interval in milliseconds).

Have you ever created a splash screen before? This how you display some info
at startup for a few seconds and the form closes and your switchboard or
other form loads (you do it in the form's OnTimer event that runs once the
value in Timer Interval has expired).

You could base the form on a query that has uses the selected field in your
continuous form as the criteria, then use the OnClick event of the textbox to
open or requery the popup form.

In the OnClick event, you could check to see if the popup form is loaded, if
it is, Requery it, if not, open it.

Private Sub myField_Click()
If CurrentProject.AllForms("myPopup").IsLoaded = True Then
Forms!myPopup.Requery
Else
DoCmd.OpenForm "myPopup"
End If

'Reset the timer to display another 5 seconds
Forms!myPopup.TimerInterval = 5000

End Sub

Steve
 
C

Claudette Hennessy

Hi Steve, I tried the pop-up route which worked fine following your advice,
thank you very much. Client is happy. I am happy.
thank you again,
Claudette
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top