Simple name reference question?

MNpoker

Board Regular
Joined
Dec 15, 2003
Messages
154
Objects:
Form Named: FormMaster
Combo Box in Form named: PortfolioSelection

I want to refer to this in VBA how do I write it out?

Works Fine here
Code:
Private Sub RunReports_Click()
    Dim frmPortfolioSelectionNumber As Double
    Dim frmPerilNumber As Double
    Dim frmAnalysisID As Long

    
    frmPerilNumber = DLookup("[Peril_Number]", "Desc_Perils", "[Peril] = '" & PerilSelection & "'")
    frmPortSelectionNumber = DLookup("[PORTINFOID]", "dbo_Portinfo", "[PortName] = '" & PortfolioSelection & "'")
    frmAnalysisID = DLookup("[ID]", "dbo_rdm_analysis", "[Name] = '" & frmAnalysisName & "'")

' Delete The current Contents of Th eFilter Table
    DoCmd.RunSQL "DELETE * FROM FiltersForReport"
' Create the new Table
    DoCmd.RunSQL "Insert Into FiltersForReport (" & _
            "IsValid, PortinfoID, Peril, ReportName, Anlsid)" & _
            "Values(-1," & frmPortSelectionNumber & "," & frmPerilNumber & ", '" & frmReportName & "' ," & frmAnalysisID & " )"


 Call MasterReportBuilderAc
End Sub

But when I call MasterReportBuilder it it either undefined (or if I Dim it a null value)

Code:
Public Sub MasterReportBuilderAc()
                 
    ' Get the Path Name
    strFullPath = CurrentDb().Name
    sXL_Path = Left(strFullPath, InStrRev(strFullPath, "\"))
    
    NewReportName = DLookup("[ReportName]", "FiltersForReport", "[Isvalid] = -1")
    
    MsgBox (sXL_Path)
    
    Set XLapp = CreateObject("excel.application")
    Set XLwb = Workbooks.Open(sXL_Path & TargetXLFile)
    Set CurDB = CurrentDb()
    
    XLapp.Visible = True
    
    XLwb.SaveAs (sXL_Path & NewReportName)
        
sDB_Path = CurrentDb().Name
             
    With XLwb.Worksheets("Primary")
        .Range("F2") = PortfolioSelection
        .Range("G2") = frmAnalysisName
    End With

    'CLEAN UP
    Set rst = Nothing
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try changing MasterReportBuilderAc to a Function instead of a Sub. Access generally won't let you call a Sub.

Denis
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,854
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top