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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking the cursor in a Form field for input 3

Status
Not open for further replies.

knuckelhead

Technical User
Aug 8, 2002
228
0
0
US
I have an unusual request from someone. I have a main and subform. The last field in the subform record is the only piece of data needing change per subform record. It is the "Profit" field that is input.

On the Main form topside, I have the usual "hands" navigation buttons for "next record".

my person wants to make the CURSOR always blink in this Profit subform field even after clicking on the "Next" record button.

so when he starts the next record, he will not need to move or click to the Profit field. he want to stay locked in the Profit field on the subform while clicking on the Next record button that is on the Main form tophalf screen.

is that possible?
 
On the OnClick event of the Next button, after all the other code, put Me.nameOfSubform.NameOfControl.SetFocus
 
Howdy knuckelhead . . .

In the [blue]OnCurrent[/blue] event of the subform:
Code:
[blue]   Me!Profit.SetFocus[/blue]

Calvin.gif
See Ya! . . . . . .
 
Hi belovedcei. i added your code but i get an error message as follows:

"Compile error. Member or data member not found."

what did i do wrong?

the Next Button in the main form now has:

Private Sub Command247_Click()
On Error GoTo Err_Command247_Click

DoCmd.GoToRecord , , acNext

Exit_Command247_Click:
Exit Sub

Err_Command247_Click:
MsgBox Err.Description
Resume Exit_Command247_Click

Me.sfrmProfit781Detail.C1% StdTarget.SetFocus

End Sub
 
Aceman. i did what you said. i believe.

in the subform sfrmProfit781Detail, i did the following in the ON Current part:

Private Sub Form_Current()
'locks the field
Me!C1%StdTarget.SetFocus
End Sub
=========================

the field name on the subform to lock is Named C1%StdTarget and the Control source is named C1%StdTarget.

so what did i do wrong?

 
Aceman: the above method gives me an error message.

Compile error, Expected: =

the Me!C1%StdTarget.SetFocus turns RED. the words StdTarget are highlighted in Blue.

What did I break??
 
Try changing your first code a little:
Code:
Private Sub Command247_Click()
On Error GoTo Err_Command247_Click

    DoCmd.GoToRecord , , acNext
Me.[sfrmProfit781Detail].[C1% StdTarget].SetFocus

Exit_Command247_Click:
    Exit Sub

Err_Command247_Click:
    MsgBox Err.Description
    Resume Exit_Command247_Click
        
End Sub

You always need square brackets when there are spaces or odd characters in the names of fields and controls. As an aside, I prefer GoToControl.
 
Remou. I would like to try your GotoControl method, whatever that is you mean.

i tried what you said and i get a different error message.
"object does not support the property or method".

i can still hit the next button but the error message appears again. ps-i guess when we figure this problem out, i have to apply to my other 3 main form "hands" buttons: front, left and end.

i took out the subform ON Current deal. was that okay?
so, in short, i only used your above code in my "Next right Hands next record" button in the On Click.
 
I thought about this and it seems to me that you should use:
Code:
Private Sub Form_Current()
DoCmd.GoToControl "sfrmProfit781Detail"
DoCmd.GoToControl "C1% StdTarget"
End Sub
I had forgotten that it is necessary to have two stages when there is a subform. Then you do not need to add anything to your 'hands'.

By the way, I did not use the right way to refer to a subform control, sorry about that, you need a Form when referring to subform controls:
[tt]Me.[sfrmProfit781Detail].[blue]Form.[/blue][C1% StdTarget].SetFocus[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top