Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / January 2005

Tip: Looking for answers? Try searching our database.

Retrun to previous focus field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kincaid - 06 Jan 2005 12:15 GMT
Hi.  I have a form with 120 textbox controls, each of which has a label
hiding a command button which when clicked, goes through a series of
functions to get text data based on user choices, MyString.  I then wish to
return to the original form (still open) original text box, and set the focus
back to it.  How can I do this programically?
    For eg:  User clicks MyControl on frmMyDataEntry.  MyControl is set
equal to varControlName.  Functions run and text returned is strMyString
along with varControlName.  I try to put it back into txbMyControl using:
    Me.varControlName = strMyString
                and I've tried
    [Forms]![fmrMyDataEntry]![varControlName] = strMyString
                 where varControlName is a string type variable.
Neither of these work.  I've also tried:
    [Forms]![frmMyDataEntry]![(varControlName)] = strMyString - NOPE.
When I do a programming aside and just set focus manually, it accepts the
strMyString with no problem.  What can I do here?  What am I doing wrong?  I
do not want to write separate procedures for each of the 120 controls.

Thanks in advance.  It's probably an easy solution I've just not run into
before.
Signature

kinacid

John Nurick - 06 Jan 2005 21:28 GMT
Hi Kincaid,

I'm not sure I understand the situation but can think of two things.

1) If you want to manipulate a control whose name is in the variable
varControlName, use the syntax
    Me.Controls(varControlName).Value = strMyString
or
    Forms("frmMyDataEntry").Controls(varControlName) = ...
depending on whether the code is in the form's own code module or in
another module.

2) If varControlname is a string variable declared in the module of one
form, it's not accessible from other modules. If you want to change its
value from code running in another module, one simple way is to replace
the variable with a textbox control (hidden, if you like) which you can
access from other forms using the syntax above.

>Hi.  I have a form with 120 textbox controls, each of which has a label
>hiding a command button which when clicked, goes through a series of
[quoted text clipped - 16 lines]
>Thanks in advance.  It's probably an easy solution I've just not run into
>before.

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
Kincaid - 06 Jan 2005 22:11 GMT
Excellent suggestions, John.  Thanks much!
Both work well and I'll use both, actually.  Thanks again.

> Hi Kincaid,
>
[quoted text clipped - 39 lines]
>
> Please respond in the newgroup and not by email.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.