Echo Method

S

Sprinks

In one use of a multi-purpose form, I make several controls invisible. I
want to do this "behind the scenes" and present the form to the screen when
complete. The following code, however, displays the form in its virgin
state, and then changes when the code is complete. Can anyone tell me how to
achieve the desired behavior?

Thank you.

Dim stDocName As String

Application.Echo False
stDocName = "Timesheet"
DoCmd.OpenForm stDocName, acNormal, , , , , "TSQueryAll"
Forms(stDocName).AllowAdditions = True
Forms(stDocName).AllowDeletions = True
Forms(stDocName).Controls("cboStaffName").Visible = True
Forms(stDocName).Controls("cboStaffName").SetFocus
Forms(stDocName).Controls("txtStaffName").Visible = False
Forms(stDocName).Controls("cmdPost").Visible = False
Application.Echo True
 
D

Douglas J. Steele

Try opening the form as hidden, and make it visible once you're done.

Dim stDocName As String

Application.Echo False
stDocName = "Timesheet"
DoCmd.OpenForm stDocName, acNormal, , , , acHidden , "TSQueryAll"
With Forms(stDocName)
.AllowAdditions = True
.AllowDeletions = True
.Controls("cboStaffName").Visible = True
.Controls("cboStaffName").SetFocus
.Controls("txtStaffName").Visible = False
.Controls("cmdPost").Visible = False
.Visible = True
End With

To make it more obvious, you could use named arguments in your OpenForm:

DoCmd.OpenForm FormName := stDocName, _
View := acNormal, _
WindowMode := acHidden , _
OpenArgs := "TSQueryAll"
 
S

Sprinks

Doug,

Thank you for your response. The behavior is still the same, however. Do
you have any other ideas?

Best regards.
Sprinks

Dim strDocName As String

Application.Echo False
strDocName = "Timesheet"
DoCmd.OpenForm FormName:=strDocName, _
View:=acNormal, _
WindowMode:=acHidden, _
OpenArgs:="TSQueryAll"

With Forms(strDocName)
.AllowAdditions = True
.AllowDeletions = True
.Controls("cboStaffName").Visible = True
.Controls("cboStaffName").SetFocus
.Controls("txtStaffName").Visible = False
.Controls("cmdPost").Visible = False
.Visible = True
End With
 
D

Douglas J. Steele

Oops. I didn't mean the Application.Echo False to be there.

If you're still experiencing the same problem after removing that line of
code, what exactly do you mean by "the behavior is still the same"?

You could try putting DoCmd.DoEvents (or .Repaint) prior to the .Visible =
True statement.
 
S

Sprinks

Doug,

After removing the line, and then after adding a .Repaint, the behavior
remained the same, meaning that the form opened appearing as it is designed,
with all controls visible. After a second or two, the textbox is replaced by
the combo box and the command button disappears.

I realized, however, that the On Open event procedure code is executed
before the With...End With code, and there are .Echo calls in *that* code to
avoid displaying some calculations until they are complete. Now that I know
I can open the form in a hidden mode, I plan to abandon .Echo calls
altogether.

Thank you for your persistance!
Sprinks
 

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