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

Setfocus on another form 1

Status
Not open for further replies.

dulla

Technical User
Feb 3, 2003
54
am trying to setfocus on a field in another form by clicking a button. keep getting runtime error 424 object required.

Private Sub Job_Find_Click()
Form_Clients_Information.Jobs_Created.SetFocus
End Sub
 
Try, so long the Form Form_Clients_Informationas is open:

Forms!Form_Clients_Information!Jobs_Created.SetFocus
 
that's strange. now i am getting:

run time error 2450. Microsoft Access can't find the form 'Clients_Information' referred to in a macro expression or visual basic code

what does this mean? thanks

ameen
 
In your original posting it looks like your Form is named Form_Clients_Information, in your 2nd posting it looks like you've asked to set focus to a Form named Clients_Information.

The syntax is:

Forms!FormName!ControlName.SetFocus
 
well i tried it both ways and i am getting the same error message. i thought vb's naming properties added a Form_ prefix to the form names. i have named the form Clients Information. Unfortuneatly none of the methods worked. I also tested it with another form that i have called workshops and access can't seem to find anything. what do think is wrong? thanks.

ameen
 
To set focus to an OPEN FORM and then to a specific Control on that Form.

Forms!YourFormName.SetFocus
Forms!YourFormName!YourControlName.SetFocus!


In simple terms, type in without any spaces:

Forms! -> your Form Name as it appears in the Database Window .SetFocus!

Forms! -> your Form Name as it appears in the Database Window, the Control Name as it appears in the Properties Window .SetFocus!

If the Form or Control Name contains spaces, enclose the whole name in Square Brackets.

The error that you're getting is because the Form is either not open or the Form Name is incorrectly spelt.

Hope this helps.
 
thanks! it was the brackets.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top