Move focus back to subform control not working

mafhobb

Registered User.
Local time
Today, 16:04
Joined
Feb 28, 2006
Messages
1,249
I have a form caller "Project Main" and a subform called "Product Manager Main". The after update event code below finds the value of several controls on both forms to later send it by e-mail. However that also changes the focus.

The last bit of code is in there to return the focus to the control in the subform it started with, however it is not happening. The focus is staying with the last control checked in the project main form (SKU#)

Does anyone know why?

Code:
Private Sub ReleaseDate_AfterUpdate()
On Error GoTo err_afterupdate
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSql As String
Dim strEmailAddress As String
Dim mail
Dim NewReleaseDate As Variant
Dim MSMDate As Variant
Dim SKU
Dim TestInput As Variant
Dim RDName As Variant
Dim ProjectName As Variant
Dim email As String
Dim RDID As String
Dim PMcommentby As Variant

'find what the new release date  is
Me.ReleaseDate.SetFocus
NewReleaseDate = Me.ReleaseDate.Text

'find the MSM date
[Forms]![Project Main]![Marketing Specialist Main]![MSM Date].SetFocus
MSMDate = [Forms]![Project Main]![Marketing Specialist Main]![MSM Date].Text

'If MSN has not been done then end
If MSMDate = "" Then
    MsgBox "MSM Not Held. No e-mail forwarded to MSM group"
    Exit Sub
End If

'Find the Project Name this e-mail refers to
[Forms]![Project Main]![Project Name].SetFocus
ProjectName = [Forms]![Project Main]![Project Name].Text
'MsgBox ProjectName

'Find the R&D ID# for this project
[Forms]![Project Main]![R&D ID#].SetFocus
RDID = [Forms]![Project Main]![R&D ID#].Text
'MsgBox [R&D ID#]

'Find the SKU# for this project
[Forms]![Project Main]![SKU#].SetFocus
SKU = [Forms]![Project Main]![SKU#].Text
'MsgBox SKU

'Move focus back to the subform
[Forms]![Project Main]![Product Manager Main]![ReleaseDate].SetFocus

Thanks

mafhobb
 
Try this:
me!<yoursubform>.setfocus
me!<yoursubform>!<yourcontrol>.setfocus
 
'Move focus back to the subform
[Forms]![Project Main]![Product Manager Main].SetFocus
[Forms]![Project Main]![Product Manager Main].[FORM].[ReleaseDate].SetFocus
 
It gives an error and does not return the focus the the control.

This is what the code looks like:
Code:
Me![Product Manager Main].SetFocus
Me![Product Manager Main]![ReleaseDate].SetFocus

and attached you'll find the message I get.

mafhobb
 

Attachments

  • untitled.JPG
    untitled.JPG
    11.8 KB · Views: 159
Hey RuralGuy, This works!

Thank you (and Scalextric too)

mafhobb
 

Users who are viewing this thread

Back
Top Bottom