Question : Macro not available to button properties

I have the attached code in a module of a workbook I'm working on.  The macro is not available when I try to attach it to a button.  Can someone help me understand why.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
Private Sub DataButton_Click()
 
Dim wrk As DAO.Workspace
Dim dbconn As DAO.Database
Dim rs As DAO.Recordset
Dim fld As DAO.Field
Dim msgoption As Long
Dim x As Integer
Dim xlws As Excel.Worksheet
Dim xlws2 As Excel.Worksheet
Dim xlrng As Excel.Range
 
Set xlws = ActiveSheet
 
Set wrk = DAO.CreateWorkspace("myworkspace", "admin", "")
Set dbconn = work.OpenDatabase("\\adpsfs\Accounting\Sondra\VerisignTransactions.accdb")
Set rs = dbconn.OpenRecordset("Select * from [T_TestTable]")
 
msgoption = MsgBox("Do you want a PivotTable?", vbYesNoCancel, "Report Type")
 
Select Case msgoption
Case vbYes
    Set xlring = xlws.Cells(4, 1)
    On Error Resume Next
    xlrng.RemoveSubtotal
    x = 1
    Next
    Set xlrng = slws.Cells(5, 1)
    xlrng.CopyFromRecordset rs
    slws.Columns.AutoFit
    Set xlrng = xlws.Columns("D:D")
    xlrng.NumberFormat = "$#,##0.00"
    Set xlrng = xlws.Range(xlws.Cells(4, 1), xlws.Cells(rs.RecordCount + 4, rs.Fields.Count))
    Set xlws2 = ActiveWorkbook.Sheets.Add
    xlws2.Name = "PivotTable"
    xlws2.PivotTableWizard xlDatabase, xlrng, xlws2.Cells(3, 1), "Test Table", False, True, True, True, False, , True, True, , , True
    xlws2.Cells(3, 1).Select
    xlws2.PivotTables("TestTable").AddFields RowFields:="ProductName", ColumnFields:="CategoryName"
    With xlws2.PivotTables("SalesByCategory").PivotFields("ProductSales")
    .Orientation = xlDataField
    .NumberFormat = "$#,##0.00"
    End With
    
    ActiveWorkbook.ShowPivotTableFieldList = False
    Set xlws2 = Nothing
    
    Case vbNo
     Set xlring = xlws.Cells(4, 1)
    On Error Resume Next
    xlrng.RemoveSubtotal
    x = 1
    Next
    Set xlrng = slws.Cells(5, 1)
    xlrng.CopyFromRecordset rs
    slws.Columns.AutoFit
    Set xlrng = xlws.Columns("D:D")
    xlrng.NumberFormat = "$#,##0.00"
    Set xlrng = xlws.Range(xlws.Cells(4, 1), xlws.Cells(rs.RecordCount + 4, rs.Fields.Count))
    xlrng.Subtotal 2, xlSum, 4, True, False, xlSummaryAbove
    xlws.Outline.ShowLevels 2
    
    Case vbCancel
    GoTo ExitStuff
    End Select
    
ExitStuff:
    Set xlws = Nothing
    Set xlws2 = Nothing
    Set xlrng = Nothing
    rs.Close
    Set fld = Nothing
    Set rs = Nothing
    dbconn.Close
    Set dbconn = Nothing
    Set wrk = Nothing
    
    
End Sub

Answer : Macro not available to button properties

My recommendation is to keep the public IP's on the outside network interface.   There is no real good reason to allow these IP's on the inside.    

From the outside you would use static nat to map a single public IP to an internal address.   The access list would control access to the server.  

Usually, any server that the public can access is placed in a DMZ.    The DMZ would have a security level in between the outside an inside so that the inside can communicate to it, but it can not get to the inside hosts by default.     This is the most secure method IMHO.  

The issue with the dns can be resolved by running a split dns setup where the internal users use an internal DNS server (i.e. AD dns), and the public uses a public name server for resolution.   That way, depending on where the machine is located, each would resolve the same FQDN to a different IP.  

Random Solutions  
 
programming4us programming4us