Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fork this print job (ACC97-SR2)

    I would like to throw a simple program fork into a current print job.
    The print job saves the current record, and then spools it to a report.
    I would like to determine which report to use (1 0f 2) i.e. 3 lines or 4 lines of text).
    The criteria for this would be the results of a combobox and that would be empty or not.

    I've tried this...

    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    End If


    '*** open the report

    If Me.cbo_DeptDivision = "" Then
    DoCmd.OpenReport "NewBadges3line", acPreview, , "[Last Name] like '" & Me![Last Name] & "'"

    Else

    DoCmd.OpenReport "NewBadges4lineb", acPreview, , "[Last Name] like '" & Me![Last Name] & "'"
    End If

    Exit_cmd_printRec_Click:
    Exit Sub

    ...but it always prints the last choice.
    What am I missing?

  2. #2
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Fork this print job (ACC97-SR2)

    If the if-then is always evaluating to false then you are probably using the wrong comparison value, in this case "". You could debug the code, put in a break point and see what value the combobox is holding when it is empty - most likely null. If this is the case change the if-then to:

    If IsNull(Me.cbo_DeptDivision)Then

  3. #3
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Fork this print job (ACC97-SR2)

    Yeah!
    That was it. <img src=/S/doh.gif border=0 alt=doh width=15 height=15>
    Thank ya kindly, Paul

  4. #4
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Fork this print job (ACC97-SR2)

    As you can see from the script below, this will not filter out individuals if they have the same last name.

    Is there an easier way to grab the ID field and use that as the criteria?

    If Me.cbo_DeptDivision = "" Then

    DoCmd.OpenReport "NewBadges3line", acPreview, , "[Last Name] like '" & Me![Last Name] & "'"


  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Fork this print job (ACC97-SR2)

    Probably. But without more information it isn't possible to guess at your table structure in order to know for certain. If every name has its own unique ID, how do you know which "Smith" to get the ID for?
    Charlotte

  6. #6
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Fork this print job (ACC97-SR2)

    I'm sorry.
    Several of my jobs seem to overlap in method.
    Here's another variant that doesn't use the above mentioned criteria (i.e. cbo_Dep_Div).

    Now it has 6 print options which are based on the value from the combo box(cboBadgeType).

    I want to filter out the ID number of one record and use that as criteria instead of the Like [Last_Name] section.

    The code is behind the on click event of the form's command button.

    Please see attached sample.
    Attached Files Attached Files

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Fork this print job (ACC97-SR2)

    In other words, you want to print a badge for the current record using its ID instead of the person's name? Here's how I would do it:

    <pre>Private Sub cmd_PrintRec_Click()
    On Error GoTo Err_cmd_PrintRec_Click
    Dim lngID As Long
    Dim strReport As String

    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    Me.cboBadgeType.Requery
    End If

    '*** open the report

    If IsNull(Me.cboBadgeType) Then
    MsgBox "Please enter a badge type via the drop down box", vbOKOnly, "Badge Type Required"

    Else
    lngID = Me.ID
    Select Case Me.cboBadgeType
    Case 1
    strReport = "lblBadge1_Deligate"
    Case 2
    strReport = "lblBadge2_ExtraExhibitor_DayPass"
    Case 3
    strReport = "lblBadge3_Guest"
    Case 4
    strReport = "lblBadge4_Speaker"
    Case 5
    strReport = "lblBadge5_Kidz"
    Case 6
    strReport = "lblBadge6_Exhibitor"
    Case Else
    strReport = "NewBadges3line"
    End Select

    DoCmd.OpenReport strReport, acPreview, , "[ID]=" & lngID

    End If

    Exit_cmd_PrintRec_Click:
    Exit Sub


    Err_cmd_PrintRec_Click:
    MsgBox Err.Description
    Resume Exit_cmd_PrintRec_Click
    End Sub</pre>

    Charlotte

Posting Permissions

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