Form Operations

  • Thread starter Thread starter Ray Hogan
  • Start date Start date
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.
 
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
 
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
 
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
 
Back
Top