Locopete99
Registered User.
- Local time
- Today, 03:12
- Joined
- Jul 11, 2016
- Messages
- 163
Hi,
Can someone help me. I cant get this code to work!
Literally all i want it to do is run different export queries based on what area the person running it is from.
Can anyone see where the glaring issues are that are stopping this from running.
Can someone help me. I cant get this code to work!
Literally all i want it to do is run different export queries based on what area the person running it is from.
Can anyone see where the glaring issues are that are stopping this from running.
Code:
Dim Holon1 As String
Dim Location As String
Dim DirName As String
Dim Response As String
DirName = "B:\" & fOSUserName & "\Register Report\Outstanding Emails\"
If Dir(DirName, vbDirectory) = "" Then
MkDir DirName
Else
End If
Holon1 = DLookup("Holon", "tbl_Holonsecurity", "[User]= '" & fOSUserName() & "'")
If Holon1 = "AA" Then
file = "AA.xlsx"
strpath = DirName & file
DoCmd.TransferSpreadsheet acExport, 9, "Qry_OutHolonAA", strpath, True
Else
If Holon1 = "AB" Then
file = "AB.xlsx"
strpath = DirName & file
DoCmd.TransferSpreadsheet acExport, 9, "Qry_OutHolonAB", strpath, True
Else
If Holon1 = "AC" Then
file = "AC.xlsx"
strpath = DirName & file
DoCmd.TransferSpreadsheet acExport, 9, "Qry_OutHolonAC", strpath, True
Else
If Holon1 = "CDT" Then
file = "CDT.xlsx"
strpath = DirName & file
DoCmd.TransferSpreadsheet acExport, 9, "Qry_OutHolonCDT", strpath, True
Else
If Holon1 = "A0" Then
file = "AA.xlsx"
file2 = "AB.xlsx"
file3 = "AC.xlsx"
file4 = "CDT.xlsx"
strpath = DirName & file
strpath2 = DirName & file2
strpath3 = DirName & file3
strpath4 = DirName & file4
DoCmd.TransferSpreadsheet acExport, 9, "Qry_OutHolonAA", strpath, True
DoCmd.TransferSpreadsheet acExport, 9, "Qry_OutHolonAB", strpath2, True
DoCmd.TransferSpreadsheet acExport, 9, "Qry_OutHolonAC", strpath3, True
DoCmd.TransferSpreadsheet acExport, 9, "Qry_OutHolonCDT", strpath4, True
Else
End If
End If
End If
End If
End If