SetFocus for control with different name

oneidalake

New member
Local time
Today, 16:32
Joined
Mar 9, 2017
Messages
10
Hi all, Been wanting to sign up for a long time and now seems like a good opportunity. I would also like to thank you all for being here.

Today, I'm trying to figure out something that I think is probably easy.

Trying to do a SetFocus when a record is selected. The target control (on another open form) that I want to have the focus contains the word “maploc” then the record number. (maploc1, maploc2, maploc3, etc). The target control is a text field.

So something like.

Dim Mappath as String
Mappath = “Forms![map].[maploc“ & me.recordnumber & “]”
Mappath.SetFocus

So, if I were on Record Number 1, I would think that the above would set the focus to...

Forms![map].[maploc1]

But it doesn’t work.

Any ideas?

Thank You!
 
Probably something like this:

Code:
With Forms![map]
    .SetFocus
    .Controls("maploc" & Me.recordnumber).SetFocus
End With
 
Probably something like this:

Code:
With Forms![map]
    .SetFocus
    .Controls("maploc" & Me.recordnumber).SetFocus
End With

Yes, that did it! Thank you so much. I knew it must be simple. I found a few articles, but nothing worked until YOU!
Thanks again!
 

Users who are viewing this thread

Back
Top Bottom