Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2004
    Posts
    7

    Unhappy Unanswered: Print current record revert to first record on form

    I am trying to print my current record that is loaded into my form. I am using the wizard to create the print record button. After I hit the button the form loads the first record and prints it out. I have a form and a subform, the form is the employees and the subform is for the employees record. I am using the employees ID as the Primary Key. Any suggestions why the Form returns to the first record and prints this record?

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Are you actually printing the Form or is it a Report you are printing?


  3. #3
    Join Date
    Mar 2004
    Posts
    7
    I would like to print directly from the form, but I can send it to a report by saving the form as a report. However, when I try to print a report it prints all the records. When I print from the form it rolls back to the first record in the table for that employee. I have a Subform in a Form. The form has a drop down list that loads the employee into the form. The subform is where the employees individual records are loaded. I used the printout function and the wizard to create a print button, neither of these work. They both roll the record in the subform back to the first record for the employee and then print the first record

  4. #4
    Join Date
    Nov 2003
    Posts
    1,487
    Set the Record Source for your Form then print it. for example:

    Me.RecordSource = myStringCriteria
    Me.Requery
    DoCmd.RunCommand acCmdPrint


    or something like that...

  5. #5
    Join Date
    Mar 2004
    Posts
    7
    Im not really that strong of a VB programmer, but the record source is setup to point at the correct table. Is reselecting the record source with code going to resolve this issue. If so can elaborate on how to implement the code in the last thread. Thanks for everyones help

  6. #6
    Join Date
    Jan 2004
    Posts
    16
    try this code

    Private Sub Command37_Click()
    On Error GoTo error

    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim acvp As Integer

    stDocName = "name of yor report"
    stLinkCriteria = "[employees]=" & Me![employees]

    If optv.Value = 1 Then
    acvp = 2
    Else
    acvp = 0
    End If

    If optr.Value = 1 Then
    DoCmd.OpenReport stDocName, acvp, , stLinkCriteria
    Else
    DoCmd.OpenReport stDocName, acvp
    End If

    error:
    If Err.Number = 3021 Then MsgBox "no data to print"
    End Sub

  7. #7
    Join Date
    Mar 2004
    Posts
    7
    The name of my form is Analyst and my report is named rptPrintRecord. Therefore here is how I modified your code. Again I do not know VB that well...so please correct any of my mistakes. I really appreciate your help.

    Private Sub Command37_Click()
    On Error GoTo error

    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim acvp As Integer

    stDocName = "rptPrintRecord"
    stLinkCriteria = "[Analyst]=" & Me![Analyst]

    If optv.Value = 1 Then
    acvp = 2
    Else
    acvp = 0
    End If

    If optr.Value = 1 Then
    DoCmd.OpenReport stDocName, acvp, , stLinkCriteria
    Else
    DoCmd.OpenReport stDocName, acvp
    End If

    error:
    If Err.Number = 3021 Then MsgBox "no data to print"
    End Sub

  8. #8
    Join Date
    Jan 2004
    Posts
    16
    put your sample here

  9. #9
    Join Date
    Mar 2004
    Posts
    7
    Im not sure what you are asking for?

Posting Permissions

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