Go to subform from form


N

NewSysAdmin

Hello,
I have a main form (RFQ_Entry_new) with a popup yes/no message box.
Depending on the users input, they should either stay on the main form or go
to the subform (PartNum2). I have tried to figure out the coding, but it
sets the focus to [RFQ_Entry_new]![T1_Delivery] whether a user clicks yes or
no. Does anyone see anything wrong with my code?

Here is my code:

Private Sub Target_Tooling_Price_AfterUpdate()
If MsgBox("Another Part Number?", vbYesNo) = vbYes Then
Forms![RFQ_Entry_new]![PartNum2].Form!Quote_Number.SetFocus
Else: Forms![RFQ_Entry_new]![T1_Delivery].SetFocus
End If
End Sub

Thank you very much!!!
 
Ad

Advertisements

D

Daniel Pineault

Where are you referring to the subform? Try something more like

Forms![RFQ_Entry_new]![PartNum2]!Form.[T1_Delivery].SetFocus
 
M

Marshall Barton

NewSysAdmin said:
Hello,
I have a main form (RFQ_Entry_new) with a popup yes/no message box.
Depending on the users input, they should either stay on the main form or go
to the subform (PartNum2). I have tried to figure out the coding, but it
sets the focus to [RFQ_Entry_new]![T1_Delivery] whether a user clicks yes or
no. Does anyone see anything wrong with my code?

Here is my code:

Private Sub Target_Tooling_Price_AfterUpdate()
If MsgBox("Another Part Number?", vbYesNo) = vbYes Then
Forms![RFQ_Entry_new]![PartNum2].Form!Quote_Number.SetFocus
Else: Forms![RFQ_Entry_new]![T1_Delivery].SetFocus
End If
End Sub


You need to set the focus to the subform control before
setting it to a control in the subform:

Private Sub Target_Tooling_Price_AfterUpdate()
If MsgBox("Another Part Number?", vbYesNo) = vbYes Then
Me![PartNum2].SetFocus
Me![PartNum2].Form!Quote_Number.SetFocus
Else
Me![T1_Delivery].SetFocus
End If
End Sub
 
Ad

Advertisements

N

NewSysAdmin

Marshall, This worked. Thank you very much! I am so grateful for these
newsgroups. They have saved me many hours and headaches.

Marshall Barton said:
NewSysAdmin said:
Hello,
I have a main form (RFQ_Entry_new) with a popup yes/no message box.
Depending on the users input, they should either stay on the main form or go
to the subform (PartNum2). I have tried to figure out the coding, but it
sets the focus to [RFQ_Entry_new]![T1_Delivery] whether a user clicks yes or
no. Does anyone see anything wrong with my code?

Here is my code:

Private Sub Target_Tooling_Price_AfterUpdate()
If MsgBox("Another Part Number?", vbYesNo) = vbYes Then
Forms![RFQ_Entry_new]![PartNum2].Form!Quote_Number.SetFocus
Else: Forms![RFQ_Entry_new]![T1_Delivery].SetFocus
End If
End Sub


You need to set the focus to the subform control before
setting it to a control in the subform:

Private Sub Target_Tooling_Price_AfterUpdate()
If MsgBox("Another Part Number?", vbYesNo) = vbYes Then
Me![PartNum2].SetFocus
Me![PartNum2].Form!Quote_Number.SetFocus
Else
Me![T1_Delivery].SetFocus
End If
End Sub
 

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