+ Reply to Thread
Results 1 to 9 of 9

Excel crashes on simple procedure

  1. #1
    Daves_Solutions
    Guest

    Excel crashes on simple procedure

    Everytime I run the following procedure excel crashes.
    Private Sub cmbDesc_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
    Shift As Integer)
    If KeyCode = 9 Then
    NewInventory.Cells(9, 4) = cmbDesc.Text
    cmbDesc.Visible = False
    NewInventory.Cells(9, 5).Select
    End If
    End Sub
    I have several other procedures that are similar that run fine. All I am
    trying to do is send the focus to the next cell in an invoice that I created
    from an embedded combo box.

    Any suggestions or help would be greatly appreciated. Thank you in advance
    for your time.
    Dave

  2. #2
    Mat P:son
    Guest

    RE: Excel crashes on simple procedure

    Well, it seems to work just fine on my box (but that's what you'd expect,
    isn't it?)

    Have you tried breaking into the VBA code and see exactly when the crash
    occurs (put a breakpoint on e.g. the first line after the If statement)? Or
    don't you even get that far?

    /MP

    "Daves_Solutions" wrote:

    > Everytime I run the following procedure excel crashes.
    > Private Sub cmbDesc_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
    > Shift As Integer)
    > If KeyCode = 9 Then
    > NewInventory.Cells(9, 4) = cmbDesc.Text
    > cmbDesc.Visible = False
    > NewInventory.Cells(9, 5).Select
    > End If
    > End Sub
    > I have several other procedures that are similar that run fine. All I am
    > trying to do is send the focus to the next cell in an invoice that I created
    > from an embedded combo box.
    >
    > Any suggestions or help would be greatly appreciated. Thank you in advance
    > for your time.
    > Dave


  3. #3
    Daves_Solutions
    Guest

    RE: Excel crashes on simple procedure



    "Mat P:son" wrote:

    > Well, it seems to work just fine on my box (but that's what you'd expect,
    > isn't it?)
    >
    > Have you tried breaking into the VBA code and see exactly when the crash
    > occurs (put a breakpoint on e.g. the first line after the If statement)? Or
    > don't you even get that far?
    >
    > /MP
    >
    > "Daves_Solutions" wrote:
    >
    > > Everytime I run the following procedure excel crashes.
    > > Private Sub cmbDesc_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
    > > Shift As Integer)
    > > If KeyCode = 9 Then
    > > NewInventory.Cells(9, 4) = cmbDesc.Text
    > > cmbDesc.Visible = False
    > > NewInventory.Cells(9, 5).Select
    > > End If
    > > End Sub
    > > I have several other procedures that are similar that run fine. All I am
    > > trying to do is send the focus to the next cell in an invoice that I created
    > > from an embedded combo box.
    > >
    > > Any suggestions or help would be greatly appreciated. Thank you in advance
    > > for your time.
    > > Dave

    I have stepped through the code and it works fine until the end sub. As soon
    as it leaves the sub and the focus return back to the worksheet excel
    crashes. I have added a text box and sent the focus there and it works fine.
    It even works fine once in ten or twenty times. Who knew? Any other ideas??

  4. #4
    Mat P:son
    Guest

    RE: Excel crashes on simple procedure

    Sorry Dave, I don't really have any useful suggestions. Hope you'll figure it
    out anyway...

    The only (very far-fetched and unlikely) leads I can think of is if you
    somehow refer to objects that are somehow going out of scope, or perhaps if
    they don't like to receive the focus for some strange reason. But I can't
    really figure out how that's supposed to fit the picture in your case...

    Good luck
    /MP

    "Daves_Solutions" wrote:

    > "Mat P:son" wrote:
    >
    > > Well, it seems to work just fine on my box (but that's what you'd expect,
    > > isn't it?)
    > >
    > > Have you tried breaking into the VBA code and see exactly when the crash
    > > occurs (put a breakpoint on e.g. the first line after the If statement)? Or
    > > don't you even get that far?
    > >
    > > /MP
    > >
    > > "Daves_Solutions" wrote:
    > >
    > > > Everytime I run the following procedure excel crashes.
    > > > Private Sub cmbDesc_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
    > > > Shift As Integer)
    > > > If KeyCode = 9 Then
    > > > NewInventory.Cells(9, 4) = cmbDesc.Text
    > > > cmbDesc.Visible = False
    > > > NewInventory.Cells(9, 5).Select
    > > > End If
    > > > End Sub
    > > > I have several other procedures that are similar that run fine. All I am
    > > > trying to do is send the focus to the next cell in an invoice that I created
    > > > from an embedded combo box.
    > > >
    > > > Any suggestions or help would be greatly appreciated. Thank you in advance
    > > > for your time.
    > > > Dave

    > I have stepped through the code and it works fine until the end sub. As soon
    > as it leaves the sub and the focus return back to the worksheet excel
    > crashes. I have added a text box and sent the focus there and it works fine.
    > It even works fine once in ten or twenty times. Who knew? Any other ideas??


  5. #5
    Mat P:son
    Guest

    RE: Excel crashes on simple procedure

    Sorry Dave, I don't really have any useful suggestions. Hope you'll figure it
    out anyway...

    The only (very far-fetched and unlikely) leads I can think of is if you
    somehow refer to objects that are somehow going out of scope, or perhaps if
    they don't like to receive the focus for some strange reason. But I can't
    really figure out how that's supposed to fit the picture in your case...

    Good luck
    /MP

    "Daves_Solutions" wrote:

    > "Mat P:son" wrote:
    >
    > > Well, it seems to work just fine on my box (but that's what you'd expect,
    > > isn't it?)
    > >
    > > Have you tried breaking into the VBA code and see exactly when the crash
    > > occurs (put a breakpoint on e.g. the first line after the If statement)? Or
    > > don't you even get that far?
    > >
    > > /MP
    > >
    > > "Daves_Solutions" wrote:
    > >
    > > > Everytime I run the following procedure excel crashes.
    > > > Private Sub cmbDesc_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
    > > > Shift As Integer)
    > > > If KeyCode = 9 Then
    > > > NewInventory.Cells(9, 4) = cmbDesc.Text
    > > > cmbDesc.Visible = False
    > > > NewInventory.Cells(9, 5).Select
    > > > End If
    > > > End Sub
    > > > I have several other procedures that are similar that run fine. All I am
    > > > trying to do is send the focus to the next cell in an invoice that I created
    > > > from an embedded combo box.
    > > >
    > > > Any suggestions or help would be greatly appreciated. Thank you in advance
    > > > for your time.
    > > > Dave

    > I have stepped through the code and it works fine until the end sub. As soon
    > as it leaves the sub and the focus return back to the worksheet excel
    > crashes. I have added a text box and sent the focus there and it works fine.
    > It even works fine once in ten or twenty times. Who knew? Any other ideas??


  6. #6
    Mat P:son
    Guest

    RE: Excel crashes on simple procedure

    Sorry Dave, I don't really have any useful suggestions. Hope you'll figure it
    out anyway...

    The only (very far-fetched and unlikely) leads I can think of is if you
    somehow refer to objects that are somehow going out of scope, or perhaps if
    they don't like to receive the focus for some strange reason. But I can't
    really figure out how that's supposed to fit the picture in your case...

    Good luck
    /MP

    "Daves_Solutions" wrote:

    > "Mat P:son" wrote:
    >
    > > Well, it seems to work just fine on my box (but that's what you'd expect,
    > > isn't it?)
    > >
    > > Have you tried breaking into the VBA code and see exactly when the crash
    > > occurs (put a breakpoint on e.g. the first line after the If statement)? Or
    > > don't you even get that far?
    > >
    > > /MP
    > >
    > > "Daves_Solutions" wrote:
    > >
    > > > Everytime I run the following procedure excel crashes.
    > > > Private Sub cmbDesc_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
    > > > Shift As Integer)
    > > > If KeyCode = 9 Then
    > > > NewInventory.Cells(9, 4) = cmbDesc.Text
    > > > cmbDesc.Visible = False
    > > > NewInventory.Cells(9, 5).Select
    > > > End If
    > > > End Sub
    > > > I have several other procedures that are similar that run fine. All I am
    > > > trying to do is send the focus to the next cell in an invoice that I created
    > > > from an embedded combo box.
    > > >
    > > > Any suggestions or help would be greatly appreciated. Thank you in advance
    > > > for your time.
    > > > Dave

    > I have stepped through the code and it works fine until the end sub. As soon
    > as it leaves the sub and the focus return back to the worksheet excel
    > crashes. I have added a text box and sent the focus there and it works fine.
    > It even works fine once in ten or twenty times. Who knew? Any other ideas??


  7. #7
    Mark Lincoln
    Guest

    Re: Excel crashes on simple procedure

    I've had problems in the past with Excel and focus, sometimes to the
    point of causing me to fundamentally restructure my code.

    Here's a wild guess. Try swapping these two lines:

    cmbDesc.Visible = False
    NewInventory.Cells(9, 5).Select

    So that you select the cell first, then hide the combo box. Then cross
    your fingers and run the code. If that doesn't work, try commenting
    out the "cmbDesc.Visible = False" line and see if the crashing goes
    away.

    Daves_Solutions wrote:
    > Everytime I run the following procedure excel crashes.
    > Private Sub cmbDesc_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
    > Shift As Integer)
    > If KeyCode = 9 Then
    > NewInventory.Cells(9, 4) = cmbDesc.Text
    > cmbDesc.Visible = False
    > NewInventory.Cells(9, 5).Select
    > End If
    > End Sub
    > I have several other procedures that are similar that run fine. All I am
    > trying to do is send the focus to the next cell in an invoice that I created
    > from an embedded combo box.
    >
    > Any suggestions or help would be greatly appreciated. Thank you in advance
    > for your time.
    > Dave



  8. #8
    Daves_Solutions
    Guest

    RE: Excel crashes on simple procedure



    "Daves_Solutions" wrote:

    > Everytime I run the following procedure excel crashes.
    > Private Sub cmbDesc_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
    > Shift As Integer)
    > If KeyCode = 9 Then
    > NewInventory.Cells(9, 4) = cmbDesc.Text
    > cmbDesc.Visible = False
    > NewInventory.Cells(9, 5).Select
    > End If
    > End Sub
    > I have several other procedures that are similar that run fine. All I am
    > trying to do is send the focus to the next cell in an invoice that I created
    > from an embedded combo box.
    >
    > Any suggestions or help would be greatly appreciated. Thank you in advance
    > for your time.
    > Dave


    I think that for some reason the computer that is to run this has a problem.
    I can run this code on three other computers and like you say it worlks fine
    for you??
    Thanks for your time and help.
    dave

  9. #9
    Daves_Solutions
    Guest

    Re: Excel crashes on simple procedure



    "Mark Lincoln" wrote:

    > I've had problems in the past with Excel and focus, sometimes to the
    > point of causing me to fundamentally restructure my code.
    >
    > Here's a wild guess. Try swapping these two lines:
    >
    > cmbDesc.Visible = False
    > NewInventory.Cells(9, 5).Select
    >
    > So that you select the cell first, then hide the combo box. Then cross
    > your fingers and run the code. If that doesn't work, try commenting
    > out the "cmbDesc.Visible = False" line and see if the crashing goes
    > away.
    >
    > Daves_Solutions wrote:
    > > Everytime I run the following procedure excel crashes.
    > > Private Sub cmbDesc_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
    > > Shift As Integer)
    > > If KeyCode = 9 Then
    > > NewInventory.Cells(9, 4) = cmbDesc.Text
    > > cmbDesc.Visible = False
    > > NewInventory.Cells(9, 5).Select
    > > End If
    > > End Sub
    > > I have several other procedures that are similar that run fine. All I am
    > > trying to do is send the focus to the next cell in an invoice that I created
    > > from an embedded combo box.
    > >
    > > Any suggestions or help would be greatly appreciated. Thank you in advance
    > > for your time.
    > > Dave

    >
    > Thanks it works on my computer I will try tomorrow on the computer that is supposed to run this program. It runs fine on three of my computers but not the one I need it too...

    thanks for your time and help.
    Dave

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1