Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Here is a snippet of code that prints a Spanish Customs Form if txtCustomsFormType= 's' or an English one if txtCustomsFormType='e'. There are times when I do not need a Customs form and I have been scratching my head as to how to tell Access to skip printing if txtCustomsFormType= "" or 'null'.

    If Me.txtCustomsFormType = "s" Then

    stDocName = "rptCustomsFormsSpanish"
    DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID

    Else

    stDocName = "rptCustomsForms"
    DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID
    End If

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You could use

    Code:
    Select Case Me.txtCustomsFormType
    Case "s"
      stDocName = "rptCustomsFormsSpanish"
      DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID
    Case "e"
      stDocName = "rptCustomsForms"
      DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID
    End Select
    or

    Code:
    If Me.txtCustomsFormType = "s" Then
      stDocName = "rptCustomsFormsSpanish"
      DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID
    ElseIf Me.txtCustomsFormType = "e" Then
      stDocName = "rptCustomsForms"
      DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID
    End If

  3. #3
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    You could use

    Code:
    Select Case Me.txtCustomsFormType
    Case "s"
      stDocName = "rptCustomsFormsSpanish"
      DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID
    Case "e"
      stDocName = "rptCustomsForms"
      DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID
    End Select
    or

    Code:
    If Me.txtCustomsFormType = "s" Then
      stDocName = "rptCustomsFormsSpanish"
      DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID
    ElseIf Me.txtCustomsFormType = "e" Then
      stDocName = "rptCustomsForms"
      DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID
    End If
    Didn't work. Here is the SQL that gets data for my rptCustomsFormsSpanish. I have it set up so that it prints the number of labels in tblOrders.CustomsForms. If I have 5 it prints 5, but I tried putting a '0' in there and it still printed.

    SELECT tblOrders.OrderID, tblOrders.CustomerID, tblOrders.ShipFirstName, tblOrders.ShipLastName, tblOrders.ShipCareOf, tblOrders.ShipAddress, tblOrders.ShipCity, tblOrders.ShipState, tblOrders.ShipPostalCode, tblOrders.ShipCountry, tblOrders.CustomsForms, IIf(tblOrders.CustomsForms>1,(qryCustomsForms.Pric e/tblOrders.CustomsForms),qryCustomsForms.Price) AS [Printed Matter], tblOrders.OrderWeight FROM tblNumberofLabels, qryCustomsForms INNER JOIN tblOrders ON qryCustomsForms.OrderID = tblOrders.OrderID WHERE (((tblNumberofLabels.NumOfLabels)<=[tblOrders].[CustomsForms] And (tblNumberofLabels.NumOfLabels)>0));

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Is CustomsForms a field in the record source of the form? If so, you could insert a line

    If Me.CustomsForms > 0

    above the code that I posted, and

    End If

    below it.


  5. #5
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    Is CustomsForms a field in the record source of the form? If so, you could insert a line

    If Me.CustomsForms > 0

    above the code that I posted, and

    End If

    below it.
    That did it! Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •