Option Compare Database
Option Explicit
Private Sub SavePDF_Click()
Dim crId As Integer
Dim strWhere As String
Dim dirDefault As String
Dim MyFileName As String
Dim ShortName As String
dirDefault = "C:\Users\yc6586\Desktop\GESUK HAD\JC test\"
strWhere = "whatever code you have in some other place"
If Me.ABS_Check = 0 And Me.DNV_Check = 0 And IsNull(Me.Other_Check) = True And Me.NA_Check = 0 Then
MsgBox ("Please choose the ThirdParty test witness")
GoTo LastLine
Else
If Combo164.ListIndex < 0 And Left(Me.InternalCode.Value, 2) = "HF" Then
MsgBox ("Please choose a FRAC FAT procedure")
GoTo LastLine
End If
blnsave = MsgBox("Are you sure you want to save this record?", vbQuestion + vbYesNo, "Save Confirmation")
Me.ChangeBy = Environ("UserName")
Me.ChangeDT = Now()
crId = Me.Form.CurrentRecord
Me.Refresh
Me.Requery
DoCmd.GoToRecord acDataForm, "E&S Assembly Forms", acGoTo, crId
strWhere = "[AssemblyWO]='" & Me!AssemblyWO & "'"
MyPath = dirDefault & Me.AssemblyWO & "-" & Me.AssemblyPartCode & "\"
If Dir(dirDefault & Me.AssemblyWO & "-" & Me.AssemblyPartCode, vbDirectory) = "" Then
MkDir (dirDefault & Me.AssemblyWO & "-" & Me.AssemblyPartCode)
End If
'Check if files are already open
MyFileName = Me.AssemblyPartCode & "-PickingList" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-ProcessCheckList_RAB" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-RABDrawing" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "Skive And Cut Length Drawing - RAB" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-RABAssemblyDrawing" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-ProcessCheckList_BIN" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-BINDrawing" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-BINAssemblyDrawing" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-CouplingDrawing" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-CrimpDrawing" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-BendRestrictor" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-BendRestrictor-MACH1" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-FAT" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-API 7K - P1,P2" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-API 7K - P3" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-16C Gas" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-API 16C FT" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-API 16D FT" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-FittingsRecordSheet" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "AssemblyTicket" & ".pdf"
GoSub CheckFile
MyFileName = Me.AssemblyPartCode & "-TestWitnessCheckList" & ".pdf"
GoSub CheckFile
Else
' Output reports
MyFileName = Me.AssemblyPartCode & "-FittingsRecordSheet" & ".pdf"
DoCmd.OutputTo acOutputReport, "FittingsRecordSheet", acFormatPDF, MyPath & MyFileName, False
MyFileName = Me.AssemblyPartCode & "-PickingList" & ".pdf"
DoCmd.OutputTo acOutputReport, "PickingList", acFormatPDF, MyPath & MyFileName, False
MyFileName = Me.AssemblyPartCode & "-AssemblyTicket" & ".pdf"
DoCmd.OutputTo acOutputReport, "AssemblyTicket", acFormatPDF, MyPath & MyFileName, False
'RAB Drawings
If Me.HoseBodyId = "RAB" Then
MyFileName = Me.AssemblyPartCode & "-ProcessCheckList_RAB" & ".pdf"
DoCmd.OutputTo acOutputReport, "ProcessCheckList_RAB", acFormatPDF, MyPath & MyFileName, False
MyFileName = Me.AssemblyPartCode & "-RABDrawing" & ".pdf"
DoCmd.OutputTo acOutputReport, "RABDrawing", acFormatPDF, MyPath & MyFileName, False
MyFileName = Me.AssemblyPartCode & "-Skive And Cut Length Drawing - RAB" & ".pdf"
DoCmd.OutputTo acOutputReport, "Skive And Cut Length Drawing - RAB", acFormatPDF, MyPath & MyFileName, False
MyFileName = Me.AssemblyPartCode & "-RABAssemblyDrawing" & ".pdf"
DoCmd.OutputTo acOutputReport, "RABAssemblyDrawing", acFormatPDF, MyPath & MyFileName, False
End If
'BIN Drawings
If Me.HoseBodyId = "BIN" Then
MyFileName = Me.AssemblyPartCode & "-ProcessCheckList_BIN" & ".pdf"
DoCmd.OutputTo acOutputReport, "ProcessCheckList_BIN", acFormatPDF, MyPath & MyFileName, False
MyFileName = Me.AssemblyPartCode & "-BINDrawing" & ".pdf"
DoCmd.OutputTo acOutputReport, "BINDrawing", acFormatPDF, MyPath & MyFileName, False
MyFileName = Me.AssemblyPartCode & "-BINAssemblyDrawing" & ".pdf"
DoCmd.OutputTo acOutputReport, "BINAssemblyDrawing", acFormatPDF, MyPath & MyFileName, False
End If
'Coupling Drawing
If (Me.HoseBodyId = "RAB" Or Me!HoseBodyId.Value = "BIN") Then
MyFileName = Me.AssemblyPartCode & "-CouplingDrawing" & ".pdf"
DoCmd.OutputTo acOutputReport, "CouplingDrawing", acFormatPDF, MyPath & MyFileName, False
End If
'Crimp Drawings
If Me!HoseBodyId.Value = "Crimp" Then
MyFileName = Me.AssemblyPartCode & "-CrimpDrawing" & ".pdf"
DoCmd.OutputTo acOutputReport, "CrimpDrawing", acFormatPDF, MyPath & MyFileName, False
End If
'Save QC Froms
If Me.BendRestrictor = True Then
MyFileName = Me.AssemblyPartCode & "-BendRestrictor" & ".pdf"
DoCmd.OutputTo acOutputReport, "BendRestrictor", acFormatPDF, MyPath & MyFileName, False
End If
If Me.BendRestrictorMACH1 = True Then
MyFileName = Me.AssemblyPartCode & "-BendRestrictor-MACH1" & ".pdf"
DoCmd.OutputTo acOutputReport, "BendRestrictor-MACH1", acFormatPDF, MyPath & MyFileName, False
End If
MyFileName = Me.AssemblyPartCode & "-FAT" & ".pdf"
DoCmd.OutputTo acOutputReport, "FAT", acFormatPDF, MyPath & MyFileName, False
Reportcode = Left(Me.HoseBodySteps, 2) ''' what is this line of code doing here??????????????
If Me.FSL <> "N/A" Then
MyFileName = Me.AssemblyPartCode & "-API 7K - P1,P2" & ".pdf"
DoCmd.OutputTo acOutputReport, "API 7K - P1,P2", acFormatPDF, MyPath & MyFileName, False
MyFileName = Me.AssemblyPartCode & "-API 7K - P3" & ".pdf"
DoCmd.OutputTo acOutputReport, "API 7K - P3", acFormatPDF, MyPath & MyFileName, False
MyFileName = Me.AssemblyPartCode & "-TestWitnessCheckList" & ".pdf"
DoCmd.OutputTo acOutputReport, "TestWitnessCheckList", acFormatPDF, MyPath & MyFileName, False
End If
If Me.GasTest = True Then
MyFileName = Me.AssemblyPartCode & "-API 16C Gas" & ".pdf"
DoCmd.OutputTo acOutputReport, "API 16C Gas", acFormatPDF, MyPath & MyFileName, False
End If
If Me.FireTest = True Then
MyFileName = Me.AssemblyPartCode & "-API 16C FT" & ".pdf"
DoCmd.OutputTo acOutputReport, "API 16C FT", acFormatPDF, MyPath & MyFileName, False
End If
If Me.API16D = True Then
MyFileName = Me.AssemblyPartCode & "-API 16D FT" & ".pdf"
DoCmd.OutputTo acOutputReport, "API 16D FT", acFormatPDF, MyPath & MyFileName, False
End If
End If
End If
LastLine:
Exit Sub
CheckFile:
ShortName = Left(InStrRev(MyFileName, "-") + 1)
If IsFileOpen(MyPath & MyFileName) Then
MsgBox ShortName & " file is open. Close the PDF and start again"
GoTo LastLine
End If
End Sub