Consulting

Results 1 to 12 of 12

Thread: 2110 error code

  1. #1

    2110 error code

    "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."

    Whenever I try to run my form this error ms occurs.
    I know it has something to do with my txtcomapny and txtItemName, but where do I move these functions so I can prevent this msg.

    txtcompany.setfocus and txtItemName.setfocus

    My code is here

    Private Sub cmdOK_Click()
    With ActiveDocument.Paragraphs(1).Range
    .InsertAfter txtCompany
    .InsertParagraphAfter
    .InsertParagraphAfter
    .InsertAfter txtClient
    .InsertParagraphAfter
    .InsertParagraphAfter
    .Font.Name = "Times New Romans"
    .Font.Size = 12
    .Font.Bold = True
    End With


    fraProduct.Visible = False

    fraClient.Visible = True

    txtItemName.SetFocus

    End Sub
    Private Sub CmdQuit_Click()
    Unload Me
    End Sub

    Private Sub cmdQuit2_Click()
    Unload Me
    End Sub
    Private Sub cmOK2_Click()
    With ActiveDocument.Paragraphs(1).Range
    .InsertAfter txtItemName
    .InsertParagraphAfter
    .InsertParagraphAfter
    .InsertAfter txtQuantity
    .InsertParagraphAfter
    .InsertParagraphAfter
    .Font.Name = "Times New Romans"
    .Font.Size = 12
    .Font.Bold = True
    End With
    End Sub
    Private Sub CommandButton3_Click()
    Unload Me
    End Sub

    Private Sub Userform_Initialize()
    fraClient.Visible = False
    fraProduct.Visible = True

    With ActiveDocument.Paragraphs.TabStops
    .ClearAll
    .Add Position:=InchesToPoints(5), _
    Alignment:=wdAlignTabRight, _
    Leader:=wdTabLeaderSpaces
    End With
    txtCompany.SetFocus
    End Sub

    Thanks for the help

  2. #2
    Good Evening.

    Where exactly does the error occur at?

    Would you please provide the Document so that we can debug it as we go rather than re-creating the file?

    Scott
    You don't understand anything until you learn it more than one way. ~Marvin Minsky

    I never teach my pupils; I only attempt to provide the conditions in which they can learn. - Albert Einstein

  3. #3
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    If you are getting that error then it probably means exactly what it is stating. The control is invisible or disabled.

  4. #4
    Alright I tinkered around with my project last night, and I was able to get rid of the error msg, however, my form still does not function properly.
    Here's an overview of my project.

    1. The userframe appears and my 1st frame(the Client Frame) appears while the product frame is not visible.
    2. The user inputs data into the various txtbxes and once all data is inputed clicks OK.
    3. This data written in the boxes should be recorded onto the spreadsheet. The 2nd Frame( the Product Frame) now appears.
    4. Lastly the user inputs the data into the txtbxes and after clicking Ok the data is transfered to the spreadsheet, the user then clicks quit and the userframe disappears.

    Alright I have programed all of the steps, but I have two gliches.
    The first is at part one of the project. When the userform is started, frame two(the product frame) is visible. Although I have made this false it continues to appear. It should only appear after the user clicks Ok on the first frame.

    The second problem is that none of my data is present on the sheet when I click Ok, however it is present once I close the userform. However, I have a hunch that it is the selection.whole story, and the selection.delete, which I programed in the initialize procedure, that is preventing the data from showing while it is in play. So this is not so much as a glich but more of a question.

    When you program the .wholestory and the .delete into a user form, is the data not suppose to appear on the spreadsheet until the userform is closed?


    If someone could review my code and possibly make suggestions about my trouble areas, It would be much appreaciated.

    Thanks for the Help

  5. #5
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Your document fails - Variable not defined." - on opening. It fails for a very good reason.

    [vba]

    Private Sub Document_Open()
    fraClient.Show
    End Sub

    [/vba]

    fraClient is not defined.

    fraClient is a Frame. It does not have a .Show method. Userforms have a .Show method.

    Further, fraClient has been re-sized to hide a sub-frame (Frame1)...which has the same structure as Frame2, a different frame. Frame1 is named fraProduct but has "Frame1" as the title line, but Frame2 is does have a title line of "Product".

    Your naming is not very good.

    CmdQuit
    cmdQuitt

    You will much much better off if you use a consistent naming convention. It does not have to be what everyone else uses, you can use your own if you like. But be consistent.

    If "cmd" is lowercase, then USE lowercase. Not upper and lower, wily-nily.

    Give everything an explicit name. I know, I know, it is a pain in the butt, but it is better in the long run. A userform should not be named "Userform". A Label should not be "Label1".

    What else?

    You never make the Product frame - Frame2, not fraProduct - Visible. You have no code for it at all.

    One way would be to make fraClient Visible=False, and then making the Product frame - the real one, not the other one - positions (Left and Top) equal the same numbers as fraClient.

    I have done this to the attached document back here. Click OK on fraClient (with some text in the textboxes as you require that), and fraClient disappears, and fraProduct (yes I named it) appears.

    What are you doing with:
    [vba]

    Selection.WholeStory
    Selection.Delete

    [/vba]What is the purpose of this????

    And IF the entire document is deleted - which it would be - how on earth is:
    [vba]

    With ActiveDocument.Paragraphs(5).Range

    [/vba]going to do anything???? If the entire document is deleted, how is there a Paragraph(5)? I am not following, but then I find your code a little difficult to follow.

    I also suggest you use standard indenting. Perhaps get Smart Indent. It is a very useful product for the VBE.

  6. #6
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    I would also suggest you learn some basics. In your other posts Steve (lucas) mentions that you are calling fraClient.Show with fraClient is a Frame. What did you do? You named the userform fraClient. Then, yes, fraClient.Show will show the userform. However, in the file here, you have a userform named Userform...but still use fraClient.Show.

    You need to learn the basics of naming and calling objects.

  7. #7
    Whoa I didn't expect such a dry report of my coding, you should of just said "you suck" and be done with it, but gee.... I'm still fresh out the box so cut me some slack. However, I did see the errors you corrected and I'am thankful. But man, before I posted my code, I thought I had cleaned it up and made it EAsier to understand, but I guess not....

    The reason for the paragraph (5) was because I wanted to move my text down the page. (reffering back to the code) Both variables that txtbxes txtClient and txtCompany produced on the worksheet, tended to bunch with the text that was created by txtquantites and txtItem. Therefore, I used the Active document to move down the texts created by frame 2, so everything would not be so bunched. Hopefully you understood that.I did it out of lack of knowledge of an alternative way. Also I couldn't name my objects properly because it kept giving messages like "this is too ambigous" or "this is an illegal name". What is a legal name? its weird some times it lets me name it properly and other times it dosen't let me name it the right way.

    But thanks once again, I'm glad you older guys take time to answer the questions of newbie coders like me.


    One last question, you said I had a smaller frame hidden behind the larger one?
    If so I agree my programming was very sloppy Yeah and
    Last edited by Viewbasic; 10-24-2008 at 12:14 PM.

  8. #8
    Yeah and how do I add Solved on a thread so people want rerefrence back to other possibly embarasing coding errors.

  9. #9
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    " you said I had a smaller frame hidden behind the larger one? "

    No...actually, I said:

    "Further, fraClient has been re-sized to hide a sub-frame (Frame1)..."

    That is not a "smaller" frame (it was in fact the same size), nor was it "behind" anything.

    fraClient was, as I said, re-sized to hide a sub-frame.

    I am attaching your original file - renamed Original.doc

    I commented out the incorrect .Show instruction so it does not fail on opening.

    Go into the VBE and look at the userform. I did nothing to the controls except make the userform bigger, and stretch the size of fraClient so you can see it has a additional frame inside it - fraProduct.

    In other words, fraClient (a Frame) has another frame inside it. Not a "smaller one hidden behind the larger". fraClient was "re-sized to hide a sub-frame".

    And you can do that. It can be a legitimate way to make parts of userform controls visible/invisible. in fact, it can be very very useful, when you dynamically re-size the userform and/or controls.

    However, one should always try and be aware of what one is doing.

  10. #10
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Oh, don't be embarrassed. That is certainly not my intention. You are starting, and we ALL started pretty much the same way. You will get there if you persist.

  11. #11
    AH! I see, I thought I had replaced that frame with another and deleted it in the process. But I didn't, thus the problems with my naming.

    I understand now.

    Thanks

  12. #12
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    You are welcome. Hope your project moves along.

Posting Permissions

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