Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2001
    Posts
    175

    Question Unanswered: Loop in report - Urgent help needed!!!!!

    How can I put the following into a loop so that I can get it for each record on a report??



    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    Dim x As Currency
    Dim xx As Currency

    If [TypeofBL] = "Prepaid" Then
    Text120 = "ORIGIN"
    Text122 = "SHIPPER"
    ElseIf [TypeofBL] = "Collect" Then
    Text120 = "DESTINATION"
    Text122 = "CONSIGNEE"
    ElseIf [TypeofBL] = "Other" Then
    Text120 = " "
    Text122 = " "
    End If

    If Expr1032 = 1 Then 'OceanFreight = Collect
    If OceanFreight <> 0 Then
    OceanFreight.Visible = True
    Label150.Visible = True
    Text102.Visible = False
    x = OceanFreight
    Else: OceanFreight.Visible = False
    Label150.Visible = False
    Text102.Visible = False
    End If
    Else
    If OceanFreight <> 0 Then 'OceanFreight = Prepaid
    Label150.Visible = True
    Text102.Visible = True
    OceanFreight.Visible = False
    xx = Text102
    Else: Label150.Visible = False
    Text102.Visible = False
    OceanFreight.Visible = False
    End If
    End If
    If Expr1034 = 1 Then 'BLFee = Collect
    If BLFee <> 0 Then
    BLFee.Visible = True
    Label151.Visible = True
    Text103.Visible = False
    x = x + BLFee
    Else: BLFee.Visible = False
    Label151.Visible = False
    Text103.Visible = False
    End If
    Else
    If BLFee <> 0 Then 'BLFee = Prepaid
    Label151.Visible = True
    Text103.Visible = True
    BLFee.Visible = False
    xx = xx + Text103
    Else: Label151.Visible = False
    Text103.Visible = False
    BLFee.Visible = False
    End If
    End If

  2. #2
    Join Date
    Jan 2003
    Location
    Aberdeen, Scotland, UK
    Posts
    168

    Re: Loop in report - Urgent help needed!!!!!

    I think That you need to put these on as fields on the report itself (you could do fancy things with recordsets etc but this would be easier).

    for example:

    in the first part change the control source of ([Text120]) to:

    =iif([TypeOfBl] = "Prepaid","origin",iif([TypeofBl] = "Collect","Destination",""))

    change the control source of ([Text122]) to:

    =iif([TypeOfBl] = "Prepaid","Shipper",iif([TypeofBl] = "Collect","Consignee",""))

    Hope the syntax was right I usually rely on Access to correct me.

    You will have to follow the same idea for the other fields.

    Any probs (or if I'm just talking tripe) let me know.

    John

  3. #3
    Join Date
    Jan 2003
    Location
    Aberdeen, Scotland, UK
    Posts
    168

    Re: Loop in report - Urgent help needed!!!!!

    The other way with the recordsets would be to:

    QryWhatever = the datasource of the report
    ---------------------------------------------------------------

    Dim Db as database
    Dim Rs as recordset

    Set db = currentdb()
    Set rs = db.openrecordset("select * from [QryWhatever]")
    rs.movefirst
    while not rs.eof
    'Your bit
    rs.movenext
    wend

    ------------------------------------------
    Hope this is what you mean.

  4. #4
    Join Date
    Sep 2001
    Posts
    175
    Thanks, I will give it a try

Posting Permissions

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