Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    83

    Unanswered: Is SetFocus Nessesary?

    When I try and call a function from a control it keeps complaining aobut not being able to modify when the control does not have focus. To get around that I just kept calling SetFocus before the call I needed. However now I need to modify 40 items, I would like to avoid 80 lines of code if possible...

    IS there any way around setfocus?

  2. #2
    Join Date
    Jun 2004
    Location
    Terrapin Nation
    Posts
    205
    What are you trying to do to the control? You shouldnt have to SetFocus for every control.

    yopu could loop through the controls like:

    Dim c as control

    For each c in me.controls
    '''code here
    next c

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by High_D
    When I try and call a function from a control it keeps complaining aobut not being able to modify when the control does not have focus. To get around that I just kept calling SetFocus before the call I needed. However now I need to modify 40 items, I would like to avoid 80 lines of code if possible...

    IS there any way around setfocus?
    Are you trying to update textboxes??? (That's what it sounds like ...) If you try to make an assignment like:

    SomeTextBox="Some Value"

    You need for that textbox to have the focus. NOW, if you use a different method:

    SomeTextBox.Value="Some Value"

    You don't get that message and the textbox gets updated ... (There are other side effects tho ... Read up on them.)
    Back to Access ... ADO is not the way to go for speed ...

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Owen is right, the Value property needs that the object in Focus. In your case don't use the value property just use your object name (in this case is TextBox)

    yourTextboxNam= "Chevorelt" ' Doesn't need Focus
    yourTextboxNam.Value= "BMW" ' Does need Focus



  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    almost...

    sometextbox.text = "something"
    requires focus set to sometextbox

    .value is the default property of a textbox so that:
    sometextbox = "something"
    and
    sometextbox.value = "something"
    are equivalent. and neither one requires the focus set to sometextbox.

    izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •