Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Focus Problem

Status
Not open for further replies.

papic1972

Technical User
Apr 10, 2003
209
0
0
AU
Hi all,

I have a form (frmJobSummary) with a subform (subfrmProduct). On this subfrm I have a combo box (cboTransport).

When I open this form, I would like the cursor to be sitting in the combo box.

I have tried the following code in the onload event of the form:
Private Sub Form_Load()
Forms!frmJobSummary!subfrmProduct.cboTransport.SetFocus
End Sub

It doesn't seem to work. Does anyone have any ideas?

Thanks in advance
 
Forms!frmJobSummary!subfrmProduct.SetFocus
Forms!frmJobSummary!subfrmProduct.cboTransport.SetFocus

(Both lines)
 
Have you tried this ?
Forms!frmJobSummary!subfrmProduct.SetFocus
Forms!frmJobSummary!subfrmProduct.Form!cboTransport.SetFocus



Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks lupins46 & PHV.


That worked a treat!
 
Greetings,

I have a form set up with five tabs on a tab control box. The problem I am having is that this is a data entry page and I have the tab control for the text boxes (of which there are several on each page) set up with mandatory input and the focus automatically goes to the next textbox to be filled with data. All works great except that if the user doen't want to complete the entire sequence of data input they can't get out of the form (Can't click the exit button as error messages require the user to enter data in whatever box they are in. Additionally, I would like the user to be able to move to another tab and fill out data in that area without completing all the data entry in other tabs

This project is for employee evaluations and depending on evaluation marks the user is required to enter a comment. The code for text boxes is as follows (note: c11q1 denotes criteria 1.1 quarter 1, etc.)

Private Sub c11q1_Exit(Cancel As Integer)
Dim intVal As Variant
intVal = c11q1

If IsNull(intVal) = True Then
MsgBox "Please enter a value"
c11q1.SetFocus
ElseIf intVal = 1 Or intVal = 2 Then
MsgBox "Enter a reason in the comments section"
mandComment = True
lblc1quickcomment.Caption = "Comment is REQUIRED"
lblc1quickcomment.ForeColor = vbRed
txtc1QuickComment.Visible = True
lblc1quickcomment.Visible = True
txtc1QuickComment.SetFocus
strQtrName = "c11q1"
Else
lblc1quickcomment.Caption = "Comment is NOT required"
lblc1quickcomment.ForeColor = vbBlue
txtc1QuickComment.Visible = True
lblc1quickcomment.Visible = True
txtc1QuickComment.SetFocus
strQtrName = "c11q1"
End If
End Sub

I set strQtrName to the current textbox and after the comment entry the next (based on a select statement) entry textbox is given focus. This is repeated until the process is complete. Like I said, the problem is to break the process to do one of two things (only) 1. to exit 2. to go to another tab

Thank you,
Steve

I set
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top