Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform's records flash 2-3 times when form is opened

Status
Not open for further replies.

Vie

Technical User
Jan 22, 2004
115
0
0
US
This isn't really a big deal but it strikes me as unprofessional-looking. When I open a particular form from the switchboard a strSQL statement is programmatically assigned to the recordsource of the form's subform. Basically, a subset of records from a few different tables. The thing that bugs me is that, although it loads all the correct data, it looks like it refreshes the recordset 2-3 times before settling in. Has anyone seen this behavior before? How can I stop this from happening? BTW, the query is sorted on two fields, the values of two other fields are generated through a couple of public functions, and one key field is dependent on the value of a third function. If I run the same sql statement in the query window, as a saved query, there's none of this flashing business. That only happens when the same SQL statement loads in the form.
 
How are ya Vie . . . . .

Bracket your code with the [blue]Application.Echo[/blue] method as follows:
Code:
[blue]   [purple][b]Application.Echo False[/b][/purple]
   [green]'Your code to open form & stuff SQL into subform Recordsource.[/green]
   DoEvents
   [purple][b]Application,Echo True[/b][/purple][/blue]
When you decide to use the [blue]Application.Echo[/blue] method, [purple]a saftey measure needs to be installed.[/purple] This is in case [blue]VBA fails while Echo is turned off[/blue] (Application.Echo False). What happens is, [purple]it appears as if everything is locked-up or dead, can't click anything and so on.[/purple] The saftey is a [blue]HotKey Combination[/blue] in an [blue]AutoKeys[/blue] macro that [blue]turns Echo back on[/blue], bringing you back to normal operations.

Installation:

In a module in the modules window, copy/paste the following code:
Code:
[blue]Public Function RestoreEcho()
   Dim Msg As String, Style As Integer, Title As String
   
   Application.Echo True
   
   Msg = "Application Echo is on!"
   Style = vbExclamation + vbOKOnly
   Title = "Echo Default Enabled!"
   MsgBox Msg, Style, Title

End Function[/blue]
Next we setup the hotkey [purple]Ctrl + E[/purple]. In the Macros Window, if you dont already have an AutoKeys macro start a new macro, else open your existing AutoKeys. The coding for the hokey should appear as follows:
Code:
[blue]Macro Name    Action       Function
----------  ----------  --------------
^E          RunCode     RestoreEcho()
            StopMacro[/blue]
Enter the [blue]^[/blue] using [blue]Shift + 6[/blue]. Close/Save the macro, saving name as [blue]AutoKeys[/blue] if a new macro.

Thats it . . . . test the hotkey combination. [blue]A confirmation window should popup![/blue]

Calvin.gif
See Ya! . . . . . .
 
That's a neat trick AceMan, but it's sort of like sweeping the dust under the carpet ;-)

I know this is a late post but I was searching for something and I came across this thread.

Vie,
Perhaps your forms are being refreshed too many times. I noticed that once in one of my applications. I was accidentally refreshing whole main forms three an even four times instead of just the individual subforms. Just a thought...
 
How are ya Edski . . . . .

[blue]Echo[/blue][/code] & [blue]Refresh[/blue][/code] are not the same. Check them out in help.



Calvin.gif
See Ya! . . . . . .
 
Hi AceMan,
I'm fine thanks.

I think you misunderstood. I simply said that turning echo off, running the code, and then on turning it back on is a neat trick and will solve the annoying flashing Vie was experiencing. What he don't see won't hurt him. But he may still have a little bit of coding somewhere that is perhaps unnecessary or needs tweaking.

Like when I was driving up the coast with my windsurfer on the roof, I heard a strange flapping noise coming from the top somewhere. So I closed the window and the noise disappeared. Problem disappeared. Right?

Wrong!

See ya.....
 
Edski . . . . .

Yeah . . . your right . . . . a great amny times I've had to track down code running outside the code bracketed by Echo . . .

Wooooooooah . . . . turkey again time! . . . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top