Results 1 to 2 of 2
  1. #1
    Dano60 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2015
    Posts
    32

    Post Conditional opening of report

    Hi Guy's,

    Have not solved my problem.
    Need to but a vbCritical where tlb_Produit.CouleurReliure is "To be determined" in the report in bold below.




    Private Sub cmd_FicheProd_Click()
    Dim sqlString, DateTerminaisonCalc As String
    Dim rs, rs2, rs3 As Recordset

    sqlString = "SELECT tbl_Commande.DateSignature, tbl_Tache.DateFinReel, tbl_Commande_Produit.ProduitID, tbl_Tache.TypeTacheID, tbl_Tache.MachineID, tbl_Commande.ID_Commande " & _


    "FROM (tbl_Commande_Produit INNER JOIN tbl_Tache ON tbl_Commande_Produit.ID_CommandeProduit = tbl_Tache.ID_CommandeProduit) INNER JOIN tbl_Commande ON tbl_Commande_Produit.CommandeID = tbl_Commande.ID_Commande " & _
    "WHERE (((tbl_Commande.DateSignature) Is Null) AND ((tbl_Commande_Produit.ProduitID)=" & NoProduit & ") AND ((tbl_Tache.TypeTacheID)=19) AND ((tbl_Tache.MachineID)=34)) OR (((tbl_Tache.DateFinReel) Is Null) AND ((tbl_Commande_Produit.ProduitID)=" & NoProduit & ") AND ((tbl_Tache.TypeTacheID)=19) AND ((tbl_Tache.MachineID)=34));"
    Set rs = CurrentDb.OpenRecordset(sqlString, dbOpenDynaset, dbSeeChanges)

    If rs.RecordCount = 0 Then
    sqlString = "SELECT tbl_Commande.DateExpedition, tbl_Commande_Produit.ProduitID, tbl_Commande.DateTerminaison " & _
    "FROM tbl_Commande_Produit INNER JOIN tbl_Commande ON tbl_Commande_Produit.CommandeID = tbl_Commande.ID_Commande " & _
    "WHERE (((tbl_Commande_Produit.ProduitID)=" & NoProduit & "));"
    Set rs2 = CurrentDb.OpenRecordset(sqlString, dbOpenDynaset, dbSeeChanges)

    If rs2.RecordCount > 0 Then
    If Nz(rs2.Fields("[DateExpedition]"), 0) <> 0 Then
    If Nz(rs2.Fields("[DateTerminaison]"), 0) = 0 Then
    tempDate1 = CalcDateTerminaison(NoProduit)
    If tempDate1 = 0 Then
    MsgBox "Certaine(s) date(s) nécessaire à la création de la fiche de production sont manquantes!", vbCritical, "Date manquante"
    Exit Sub
    Else
    tempDate2 = "#" & Month(tempDate1) & "-" & Day(tempDate1) & "-" & Year(tempDate1) & "#"
    End If
    sqlString = "UPDATE tbl_Commande_Produit INNER JOIN tbl_Commande ON tbl_Commande_Produit.CommandeID = tbl_Commande.ID_Commande SET tbl_Commande.DateTerminaison = " & tempDate2 & " " & _
    "WHERE (((tbl_Commande_Produit.ProduitID)=" & NoProduit & "));"

    CurrentDb.Execute sqlString, dbFailOnError
    End If
    sqlString = "UPDATE tbl_Produit SET tbl_Produit.ImpressionFicheProd = 1 " & _
    "WHERE (((tbl_Produit.ID_Produit)=" & NoProduit & "));"
    CurrentDb.Execute sqlString, dbFailOnError


    DoCmd.OpenReport "rpt_FicheProductionAupel", acViewPreview, , "[tbl_Produit].[ID_Produit]=" & NoProduit, , "Produit"
    DoCmd.RunCommand (acCmdZoom100)

    Else
    MsgBox "Il n'y a pas de date d'expédition!", vbCritical, "Date d'expédition"
    End If
    End If
    rs2.Close

    Else
    MsgBox "Certaine(s) date(s) nécessaire à la création de la fiche de production sont manquantes!", vbCritical, "Date manquante"
    End If

    rs.Close


    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,891
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Conditional Value in report design?
    By ieatglitter in forum Reports
    Replies: 2
    Last Post: 11-30-2014, 02:37 AM
  2. Replies: 1
    Last Post: 05-27-2013, 08:54 AM
  3. Creating Conditional Report!! Please help me!
    By ahmad6483 in forum Reports
    Replies: 3
    Last Post: 05-08-2013, 03:21 PM
  4. Conditional formating in a report
    By msmithtlh in forum Programming
    Replies: 12
    Last Post: 03-20-2013, 02:25 PM
  5. Replies: 1
    Last Post: 01-10-2012, 03:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums