Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Command not available (2002)

    I get different error messages i.e. copy command not available and can not go to control.
    Private Sub cboCompanyName_Enter()
    Me.cboCompanyName.Dropdown
    End Sub

    Private Sub cboCompanyName_AfterUpdate()
    DoCmd.GoToControl "AccountNumberCalc"
    DoCmd.RunCommand acCmdCopy
    DoCmd.GoToControl "AccountNumber"
    DoCmd.RunCommand acCmdPaste
    DoCmd.GoToControl "cboContactName"
    End Sub

    Don't have a clue what I'm doing wrong.
    Frank <img src=/S/drop.gif border=0 alt=drop width=23 height=23>

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    352
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Command not available (2002)

    Why jump around? Do you need to lose weight?

    Why not just do

    Private Sub cboCompanyName_AfterUpdate()
    Me.accountnumber=me.accountnumbercalc
    End Sub
    David Grugeon
    Brisbane Australia

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Command not available (2002)

    Well I have been getting a little bulge.
    Thanks for the diet tip. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Frank

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Oh Oh!

    I put the code snipet in and my controls are blinking like a christmas tree.
    I think there's some circular argument going on.

    Private Sub cboAccount_Enter()
    Me.cboAccount.Dropdown
    End Sub

    Private Sub cboAccount_AfterUpdate()
    DoCmd.GoToControl "cboCompanyName"
    End Sub

    Private Sub cboCompanyName_Enter()
    Me.cboCompanyName.Dropdown
    End Sub

    Private Sub cboCompanyName_AfterUpdate()
    Me.AccountNumber = Me.AccountNumberCalc
    DoCmd.GoToControl "cboContactName"
    End Sub

    Private Sub cboContactName_Enter()
    DoCmd.RunCommand acCmdRefresh
    Me.cboContactName.Dropdown
    End Sub

    Frank <img src=/S/surrender.gif border=0 alt=surrender width=31 height=23>

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    352
    Thanks
    0
    Thanked 1 Time in 1 Post

    Ooops!

    I think the refresh is triggering everything's after update, which triggers the goto control cboContactName, which triggers the cboContactName_Enter() ...

    How about trying without the DoCmd.GoToControl "cboContactName". Unfortunately I haven't time to try this at the moment. but I think that should work.

    I also use Me.cboContactName.SetFocus instead of GoToControl. Not sure if that makes any difference.

    What is the event which normally triggers the AfterUpdate event of one of your controls. If it is the user moving to another control, pressing enter, or tab then why do you need to use GoToControl (or setfocus) at all?
    David Grugeon
    Brisbane Australia

  6. #6
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Try Debugging...

    One thing you will undoubtedly enjoy discovering is the rich set of debugging tools in the VB/VBA environment.

    There are many ways to enter Debug mode - perhaps the easiest is to set a breakpoint in the code. To set a breakpoint all you have to do is click in the vertical bar immediately left of where the code is entered in any VBA window. You will see a big red dot appear, indicating that the code will break when it reaches that line during execution. (You can also select a line of code and press F9 to toggle a breakpoint on or off.)

    To test this, simply open the form (Form view) and do whatever it takes to execute the line of code you've selected as a breakpoint. You will see the current line highlighted in yellow in the VBA window. You can then use the VCR-like controls found under the Debug menu to step through each line of code to find what is causing the problems you're experiencing. While in debug mode, you can see the current value of any control or variable using the Locals window. You can have expressions evaluated by typing them into the Immediate window. And you can also add variables to be tracked so that you know exactly when your variables are changing using the Watch window.

    In your current situation I would recommend setting a breakpoint at the very first event in your series of events so you can follow the entire process to find where the problem lies. Be careful to put the breakpoint on the actual line of code to be executed (not the Private Sub... line).

    (FYI: You can also type the word STOP in code to trigger a breakpoint.)

    Hope this helps

  7. #7
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Try Debugging...

    Thanks Mark I will use the debug window soon.

    Well this works-not very elegant code but it works:

    Private Sub cboAccount_Enter()
    Me.cboAccount.Dropdown
    End Sub

    Private Sub cboAccount_AfterUpdate()
    DoCmd.GoToControl "cboCompanyName"
    End Sub

    Private Sub cboCompanyName_Enter()
    Me.cboCompanyName.Dropdown
    End Sub

    Private Sub cboCompanyName_AfterUpdate()
    Me.cboContactName.SetFocus
    Me.Recalc
    Me.cboContactName.SetFocus
    End Sub

    Private Sub cboContactName_Enter()
    Me.cboContactName.Dropdown
    End Sub

    Private Sub cboContactName_AfterUpdate()
    Me.Description.SetFocus
    End Sub

    Private Sub Description_Enter()
    SendKeys "{Tab}"
    Me.AccountNumber = Me.AccountNumberCalc
    End Sub

    Frank

Posting Permissions

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