Form Operations

R

Ray Hogan

Hi,
I have a Form (frmRegister) on which I have a Command Button to opem Form
(frmResort).
When I close frmResort with a Command Button, I want to to go to a specifi
field on frmRegister.
Please advise the code I need to to add to the following;
Private Sub cmdCloseForm_Click()
On Error GoTo Err_cmdCloseForm_Click

DoCmd.Close

Exit_cmdCloseForm_Click:
Exit Sub

Err_cmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_cmdCloseForm_Click

End Sub
Thanking you in anticipation.
Regards.
Rayh.
 
F

fredg

Ray said:
Hi,
I have a Form (frmRegister) on which I have a Command Button to opem Form
(frmResort).
When I close frmResort with a Command Button, I want to to go to a specifi
field on frmRegister.
Please advise the code I need to to add to the following;
Private Sub cmdCloseForm_Click()
On Error GoTo Err_cmdCloseForm_Click

DoCmd.Close

Exit_cmdCloseForm_Click:
Exit Sub

Err_cmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_cmdCloseForm_Click

End Sub
Thanking you in anticipation.
Regards.
Rayh.
Simplest way, if you always want to have the same field get the focus
whenever frmRegister is opened is to code the frmRegister's Open event:
Me![FieldName].SetFocus

If you only wish to have that field get the focus when closing
frmResort, not at other times, then code the frmResort Close event:

Docmd.Close acForm, Me.Name
DoCmd.OpenForm "frmRegister", , , , , , "Resort"

Code the frmRegister Load event:
If Me.OpenArgs = "Resort" Then
Me! [FieldName].SetFocus
End If
 
R

Ray Hogan

Hi Fred,
Thank you for you prompt rely.
I have added the code as suggested, but it stops on the "DoCmd.Close acForm,
Me.Name"

Private Sub Form_Close()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "frmRegister", , , , , , "Resort"
End Sub
Please advise. I should advise that the field I need to go to on FrmRegister
is "cmdResort"
Regards.
Rayh.
fredg said:
Ray said:
Hi,
I have a Form (frmRegister) on which I have a Command Button to opem Form
(frmResort).
When I close frmResort with a Command Button, I want to to go to a specifi
field on frmRegister.
Please advise the code I need to to add to the following;
Private Sub cmdCloseForm_Click()
On Error GoTo Err_cmdCloseForm_Click

DoCmd.Close

Exit_cmdCloseForm_Click:
Exit Sub

Err_cmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_cmdCloseForm_Click

End Sub
Thanking you in anticipation.
Regards.
Rayh.
Simplest way, if you always want to have the same field get the focus
whenever frmRegister is opened is to code the frmRegister's Open event:
Me![FieldName].SetFocus

If you only wish to have that field get the focus when closing
frmResort, not at other times, then code the frmResort Close event:

Docmd.Close acForm, Me.Name
DoCmd.OpenForm "frmRegister", , , , , , "Resort"

Code the frmRegister Load event:
If Me.OpenArgs = "Resort" Then
Me! [FieldName].SetFocus
End If
 
F

fredg

Ray said:
Hi Fred,
Thank you for you prompt rely.
I have added the code as suggested, but it stops on the "DoCmd.Close acForm,
Me.Name"

Private Sub Form_Close()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "frmRegister", , , , , , "Resort"
End Sub
Please advise. I should advise that the field I need to go to on FrmRegister
is "cmdResort"
Regards.
Rayh.
fredg said:
Ray said:
Hi,
I have a Form (frmRegister) on which I have a Command Button to opem Form
(frmResort).
When I close frmResort with a Command Button, I want to to go to a specifi
field on frmRegister.
Please advise the code I need to to add to the following;
Private Sub cmdCloseForm_Click()
On Error GoTo Err_cmdCloseForm_Click

DoCmd.Close

Exit_cmdCloseForm_Click:
Exit Sub

Err_cmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_cmdCloseForm_Click

End Sub
Thanking you in anticipation.
Regards.
Rayh.
Simplest way, if you always want to have the same field get the focus
whenever frmRegister is opened is to code the frmRegister's Open event:
Me![FieldName].SetFocus

If you only wish to have that field get the focus when closing
frmResort, not at other times, then code the frmResort Close event:

Docmd.Close acForm, Me.Name
DoCmd.OpenForm "frmRegister", , , , , , "Resort"

Code the frmRegister Load event:
If Me.OpenArgs = "Resort" Then
Me! [FieldName].SetFocus
End If


Hmmm. Works fine for me.

Try it this way.
DoCmd.Close acForm, "frmResort"
DoCmd.OpenForm "frmRegister", , , , , , "Resort"

In the Form frmRegister Load event:
If Me.OpenArgs = "Resort" then
[cmdResort].SetFocus
End If
 

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

Similar Threads

SetFocus on Form 1
close form 2
Use Re-query and RepaintObject Action 2
Navigate Subform to Form 1
Form AfterUpdate 2
Command Button on Report 1
Run-time Error 2585: Unable to Close Form 2
SetValue 5

Top