I'm sorry, I should have been more clear. I'm having a hard time
understanding the "Event Procedures" and what it is they are trying to do,
and where they are trying to grab information from. I'm going to try and buy
a book on Visual Basic in the next day or two to try and figure it out. For
example, Here is just one "Event Procedure that I'm trying to figure out"
As far as exchange, I'm not sure. Cash, Brand New Dell 16 Port Hub, Brand
new Ethernet cards, baseball, football, basketball cards. I don't know, I'm
just doing this on my own, just trying to learn it and become more familiar
with this stuff.
Option Compare Database
Option Explicit
Private Sub CmdExit_Click()
On Error GoTo Err_CmdExit_Click
DoCmd.CLOSE
Exit_CmdExit_Click:
Exit Sub
Err_CmdExit_Click:
MsgBox Err.DESCRIPTION
Resume Exit_CmdExit_Click
End Sub
Private Sub cmdUpdate_Click()
Dim bSelected As Boolean
'Initialize
bSelected = False
'Delete US and INV AFEs (excluding CFOL)
DoCmd.SetWarnings False
DoCmd.OpenQuery "qDelete_NONCFOL_AFES"
DoCmd.SetWarnings True
'Check for a Source selection
If cboSource = "UNKNOWN" Then
MsgBox "Select a Source - it can not be left as UNKNOWN!",
vbCritical, "Source Missing"
Exit Sub
End If
'Check for a Business Unit selection
If IsNull(cboBusinessUnit) Then
MsgBox "Select a Business Unit!", vbCritical, "Business Unit Missing"
Exit Sub
End If
'Check for a Year
If IsNull(cboYear) Then
MsgBox "Select a Year!", vbCritical, "Year Missing"
Exit Sub
End If
Dim lngFlags As Long
Dim gfni As adh_accOfficeGetFileNameInfo
Dim sFileName As String
On Error GoTo HandleErrors
'Initialize
sFileName = IIf(IsNull(Me!txtResults), "", Me!txtResults)
With gfni
.lngFlags = lngFlags
' Make sure not to pass in Null values. adhOfficeGetFile
' doesn't like that, and often GPFs.
.strFilter = "MS Excel (*.xls)|All Files (*.*)"
.lngFilterIndex = 0
.strFile = "CAPEX REPORT.xls"
.strDlgTitle = "Open Accounting MS Excel"
.strOpenTitle = "Open"
.strInitialDir = ""
End With
'Mode = 0 is to OPEN, (versus 1 = SAVE)
If adhOfficeGetFileName(gfni, 0) = adhcAccErrSuccess Then
Me!txtResults = Trim(gfni.strFile)
'Get the AFE data
bOK = ImportBusinessUnitCapex(txtResults, cboSource,
cboBusinessUnit, cboYear)
End If
DoCmd.OpenQuery "qDELETE_0_AFE_RECORDS"
If bOK Then
MsgBox "Import successful!", vbExclamation, "IMPORT SUCCESSFUL"
Else
MsgBox "Import unsuccessful!", vbCritical, "IMPORT UNSUCCESSFUL"
End If
ExitHere:
Exit Sub
HandleErrors:
MsgBox "Error: " & Err.DESCRIPTION & " (" & Err.Number & ")"
Resume ExitHere
Exit Sub
End Sub
Private Function ImportBusinessUnitCapex(sFileName As String, sSource As
String, sBusinessUnit As String, sYear As String) As Boolean
Dim sSQL As String, sWhere As String
Dim bWhere As Boolean
Dim sTable(11) As String
Dim J As Byte
On Error GoTo Err_ImportBusinessUnitCapex
'Initialize
sTable(9) = "AFE_DOLLARS"
sTable(10) = "AFE_DOLLARS_OTHER"
sTable(11) = "CURRENT_AFE_LIST"
'Build the Where clause
sWhere = ""
bWhere = False
'Source
If sSource <> "**ALL**" Then
sWhere = " WHERE [SOURCE] = '" & sSource & "'"
bWhere = True
End If
'Business Unit
If sBusinessUnit <> "**ALL**" Then
If bWhere Then
sWhere = sWhere & " AND [REGION] = '" & sBusinessUnit & "'"
Else
sWhere = " WHERE [REGION] = '" & sBusinessUnit & "'"
bWhere = True
End If
End If
'Project Year
If sYear <> "**ALL**" Then
If bWhere Then
sWhere = sWhere & " AND [PROJECT_YEAR] = " & sYear
Else
sWhere = " WHERE [PROJECT_YEAR] = " & sYear
bWhere = True
End If
End If
'Add the ALLOW_DELETE part
'goofy 2002.08.02 sWhere = sWhere & IIf(InStr(sWhere, "WHERE") > 0, " AND
", " WHERE ") & " [ALLOW_DELETE] = Yes;"
'Delete old AFE related records and import new ones
'=============
DoCmd.SetWarnings False
'Get the AFE data
bOK = GetCurrentAFEList(Me!txtResults, "AFE_DOLLARS",
"IRR_AFE_DOLLARS", sWhere)
DoCmd.SetWarnings True
'Modify certain AFE names with Business Unit names as suffixes
Modify_AFE_Suffixes
'OK
ImportBusinessUnitCapex = True
Exit Function
Err_ImportBusinessUnitCapex:
MsgBox "Error: " & Err.DESCRIPTION & " (" & Err.Number & ")"
ImportBusinessUnitCapex = False
Resume Next
End Function