How do I get functions to work with Tab Control?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • damicomj
    New Member
    • Sep 2010
    • 34

    How do I get functions to work with Tab Control?

    Everything is working fine on my form without the tab control. I added the tab control to cut down on screen space. Ever since I added the tab control, there is one page in which the command buttons do nothing. There are about 5 command buttons that, when clicked, do not perform their specified action. I will list two of them for a examples.

    This command button is on a tab located on pgAttachments:

    Code:
    Private Sub cmdView_Click()
    VBA.Shell "Explorer.exe " & Chr(34) & Attachment & Chr(34), vbNormalFocus
    End Sub
    Attachment is a textbox located on the tab called pgLease


    This command button also does noting when clicked, but here is the code being used:

    Code:
    Private Sub cmdAttachSLA_Click()
    Dim strTable As String, strColumns As String, strValues As String
    Dim strFile As String
    Dim strFilter As String
    Dim SLAcounter As Integer
    Dim strSQL As String
    Dim strSLAName As String
    
    strSLAName = InputBox("What would you like to name this SLA?" & vbCrLf & vbCrLf & "Example: SLA 2", "SLA Name")
    
    If Len(strSLAName) > 1 Then
    
    strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
    strFile = ahtCommonFileOpenSave( _
                                        OpenFile:=True, _
                                        Filter:=strFilter, _
                        Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)
    
    strTable = "tblSLA"
    strColumns = "(LeaseID, SLAAttachment, SLAName)"
    strValues = "(" & Me.LeaseID & ", '" & strFile & "', '" & strSLAName & "')"
    
    strSQL = "INSERT INTO " & strTable & " " & strColumns & " VALUES " & strValues & ";"
    
    DoCmd.RunSQL strSQL
    
    End If
    
    cmbSLA.Requery
                        
    countSLAs
    End Sub
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1288

    #2
    First, note that you do not have any error handling in your code. This greatly handicaps your ability to identify error events. First, this time and every time, put error handling in your vba code. It should look something like this:

    Code:
     On Error GoTo cmdAttachSLA_Click_Error
    
       On Error GoTo 0
       Exit Sub
    
    cmdAttachSLA_Click_Error:
    
        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdAttachSLA_Click of VBA Document Form_frmwhatever"
         Resume Next
    After we get an error message we'll have a better chance of solving your problem.

    Jim

    Comment

    • OldBirdman
      Contributor
      • Mar 2007
      • 675

      #3
      I'm going to take a wild guess here.

      When you moved them to a page on the Tab Control, did you loose the link from the control to the code? Check the Event 'On Click' to see if it still says [Event Procedure], and if no, then fix it. My guess wrong? Then forget this post.

      Comment

      • damicomj
        New Member
        • Sep 2010
        • 34

        #4
        Thank you both for your time.

        Comment

        Working...