469,166 Members | 2,174 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,166 developers. It's quick & easy.

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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdView_Click()
  2. VBA.Shell "Explorer.exe " & Chr(34) & Attachment & Chr(34), vbNormalFocus
  3. End Sub
  4.  
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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAttachSLA_Click()
  2. Dim strTable As String, strColumns As String, strValues As String
  3. Dim strFile As String
  4. Dim strFilter As String
  5. Dim SLAcounter As Integer
  6. Dim strSQL As String
  7. Dim strSLAName As String
  8.  
  9. strSLAName = InputBox("What would you like to name this SLA?" & vbCrLf & vbCrLf & "Example: SLA 2", "SLA Name")
  10.  
  11. If Len(strSLAName) > 1 Then
  12.  
  13. strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
  14. strFile = ahtCommonFileOpenSave( _
  15.                                     OpenFile:=True, _
  16.                                     Filter:=strFilter, _
  17.                     Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)
  18.  
  19. strTable = "tblSLA"
  20. strColumns = "(LeaseID, SLAAttachment, SLAName)"
  21. strValues = "(" & Me.LeaseID & ", '" & strFile & "', '" & strSLAName & "')"
  22.  
  23. strSQL = "INSERT INTO " & strTable & " " & strColumns & " VALUES " & strValues & ";"
  24.  
  25. DoCmd.RunSQL strSQL
  26.  
  27. End If
  28.  
  29. cmbSLA.Requery
  30.  
  31. countSLAs
  32. End Sub
  33.  
Jan 3 '11 #1

✓ answered by OldBirdman

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.

3 1380
jimatqsi
1,259 Expert 1GB
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:

Expand|Select|Wrap|Line Numbers
  1.  On Error GoTo cmdAttachSLA_Click_Error
  2.  
  3.    On Error GoTo 0
  4.    Exit Sub
  5.  
  6. cmdAttachSLA_Click_Error:
  7.  
  8.     MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdAttachSLA_Click of VBA Document Form_frmwhatever"
  9.      Resume Next
After we get an error message we'll have a better chance of solving your problem.

Jim
Jan 3 '11 #2
OldBirdman
675 512MB
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.
Jan 3 '11 #3
Thank you both for your time.
Jan 4 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Dan Sikorsky | last post: by
reply views Thread by Sarah J | last post: by
9 posts views Thread by Piccolo Pete | last post: by
12 posts views Thread by Arash Partow | last post: by
9 posts views Thread by Ross | last post: by
4 posts views Thread by colin spalding | last post: by
2 posts views Thread by Andrea Taverna | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.