Butona iki raporuda açtıracak kod eklemişsiniz. Haliyle ikisini de yazdırıyor.
YazıcıSec Formunun tıklandığında olayındaki kodu aşağıdaki ile değiştir.
Dim prt As Printer
Dim stDocName As String
Set prt = Application.Printers(Me!YaziciSec.Value)
Set Application.Printer = prt
If RaporAcikMi("GenelRapor") = True Then
DoCmd.OpenReport "GenelRapor", acPreview
Else
DoCmd.OpenReport "kalan_tplm", acPreview
End If
DoCmd.Close acForm, "YaziciSec"
DoCmd.PrintOut acPages, 1, 1
If RaporAcikMi("GenelRapor") = True Then
DoCmd.Close acReport, "GenelRapor"
Else
DoCmd.Close acReport, "kalan_tplm"
End If
Set Application.Printer = Nothing
Gelen Kod isimli modüle aşağıdaki fonksiyonu ekle
Function RaporAcikMi(GRaporAdi As String) As Boolean
On Error GoTo Hata
If Application.CurrentProject.AllReports(GRaporAdi).IsLoaded = True Then
RaporAcikMi = True
Else
RaporAcikMi = False
End If
Hata_Exit:
On Error Resume Next
Exit Function
Hata:
MsgBox Err.Number & "-" & Err.Description
Resume Hata_Exit
End Function