Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004
    Location
    California
    Posts
    502

    Unanswered: Command Buttons On Tabbed Form

    TAB 1
    10 command buttons that do nothing but run a report . . .

    Code:
    Private Sub Command31_Click()
    DoCmd.OpenReport "rptReMaxDesert", acViewPreview, ""
    End Sub
    All buttons work well . . . UNITL . . .

    TAB 2

    3 command buttons that work well but somehow have interfierd with ALL of the command buttons on TAB 1 to where TAB 1 buttons coding is completely gone!

    What is the significence of the number (31 in this example) on Private Sub Command31_Click() ?

    Without have to start all over is there a way to correct this?
    Renumber the buttons?

    Thanks much . . . Rick

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    If my cloak of invisibility isn't still on, the number is how the wizard will name the control (first command button will be 1, and so on). In your example, the name of the control is "Command31". No 2 controls can have the same name on the same form, and it sounds like that's what's happened to you. Tabs are irrelevant here, as they're all on the same form.

    In reality, you shouldn't leave them named that way anyway. When you're working in your code, you know what "cmdMaxDesertRpt" does; you have no idea what "Command31" does.
    Paul

  3. #3
    Join Date
    Mar 2004
    Location
    California
    Posts
    502

    I'm so frustrated I could scream!!!

    NEW FORM
    NEW COMMAND BUTTON

    This still fails???

    Code:
    Private Sub CommandCBAllRpt_Click()
    DoCmd.OpenReport "rptCBALL", acViewPreview, ""
    End Sub
    What am I missing here?

    Thanks . . . Rick

  4. #4
    Join Date
    Mar 2004
    Location
    California
    Posts
    502

    ReName Command Button?

    If I remove the number 3 from Private Sub Command3_Click() and change it to Private Sub CommandOpenrptName_Click() the button fails.

    What is the signifigence of the number? Just the order?

    How, or can I rename the Private Sub Command3_Click() and still have it function?

    Thanks . . . Rick

  5. #5
    Join Date
    May 2005
    Posts
    1,191
    This still fails???
    How does it fail? Can you post the error message?
    Me.Geek = True

  6. #6
    Join Date
    Mar 2004
    Location
    California
    Posts
    502

    Uh . . . my stupid side reared it's ugly head again!

    Okay . . . I'm calm now. HA!

    It all had to do with the number on the Commandbutton and on the properties sheet and Code section.

    Once I understood that I figuered it out. Those numbers (ie, Command3) MUST MATCH or it won't work.

    In the Code section AND the property sheet could I rename the Command3 button to "rptOpenReportName" and it will work?

    I'll have to try that.

    Thanks to all who have guided me.

    Rick

  7. #7
    Join Date
    Sep 2006
    Posts
    265
    Tip: Take the commands out of the form and create a module as these are re-useable. Maintain Tab_No on your tabs and put the contols on the parent testing for which tab has the focus.

    if Tab_No = 1 then
    doccmd.OpenReport "rptOpenReportName1"
    else if Tab_No = 2 then
    do.cmd.OpenReport "rptOpenReportName2"
    end if

Posting Permissions

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