Multiple If Statements with multiple Cmd's

Microsoft Office access v.2007
December 21, 2011 at 23:55:50
Specs: Windows XP, Optiplex 980
I am having trouble getting a full understanding of how to use multiple if statements. I want to first use the msgbox, and if vb yes then import the two spreadsheets below with if statements here checking first if a file is present, is so then import them, if not import the blank file for both imports. Not really sure how to word this correctly but I and getting a compile error, Block If without End If.

Private Sub Command27_Click()

If MsgBox("Are you sure you want to import today's JRC Manifest?", vbYesNo, "Importing") = vbYes Then
If Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Inbound\In.xlxs") = "" Then
DoCmd.RunSavedImportExport "Import-In"
Else
DoCmd.RunSavedImportExport "Import-Inblk"
If Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Outbound\Out.xlxs") = "" Then
Else
DoCmd.RunSavedImportExport "Import-Outblk"
DoCmd.Requery ""

End If

End Sub


See More: Multiple If Statements with multiple Cmds

Report •


#1
December 22, 2011 at 03:55:15
Ok, I got my answer. Thx anyways. For those that are curios the code is below.

[code]
Private Sub Command27_Click()
'Get confirmation from user
If vbYes = MsgBox("Are you sure you want to import today's JRC Manifest?", vbYesNo, "Importing") Then
'Check for file existance Inbound
If Len(Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Inbound\In.xlsx")) = "0" Then
'File does not exist, import blank sheet
DoCmd.RunSavedImportExport "Import-Inblk"
Else
'File exists, import
DoCmd.RunSavedImportExport "Import-In"

End If


'Check for file existance outbound
If Len(Dir("\\lnknfs01\share\rcsw\c-1\0-II MEF (FWD) (1 MAR 2011)\0-Manpower Section\JRC Manifest\Outbound\Out.xlsx")) = "0" Then
'File does not exist, import blank sheet
DoCmd.RunSavedImportExport "Import-Outblk"
Else
'File exists, import
DoCmd.RunSavedImportExport "Import-Out"
End If

'Done importing, update screen
DoCmd.Requery ""
End If

End Sub[/code]


Report •
Related Solutions


Ask Question