Code a button

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Grant

    #1

    Code a button

    Can I add/code a button on my form that will print only the selected record?

    Thanks
    Grant Dayton




  • Trevor Best

    #2
    Re: Code a button

    Grant wrote:
    [color=blue]
    > Can I add/code a button on my form that will print only the selected record?[/color]

    Yes.
    ;-)

    Comment

    • Trevor Best

      #3
      Re: Code a button

      Grant wrote:
      [color=blue]
      > Can I add/code a button on my form that will print only the selected record?[/color]

      (air code)
      Sub cmdPrint2ndReco rd_Click()
      Dim strBookMark as string
      If Me.Dirty Then
      Msgbox "Sorry, you have to save or abandon the current record first"
      Else
      strBookmark = Me.bookmark ' save current pos
      With Me.RecordsetClo ne
      .MoveFirst ' go to first rec
      .Movenext ' go to second rec
      Me.Bookmark = .Bookmark ' sync form
      ' insert print code here [1]
      End With
      Me.Bookmark = strBookmark ' return to where we was
      End if
      End Sub

      [1] Sorry, I get stuck with the simple things, I assume you know how to
      do that bit or else use the command button wizard to print the form and
      copy the line of code out of that.

      Comment

      • Albert D. Kallal

        #4
        Re: Code a button

        yes, you can use:


        Me.Refresh

        docmd.OpenRepor t "yourREport",ac ViewPreview,,"i d = " & me.ID


        --
        Albert D. Kallal (Access MVP)
        Edmonton, Alberta Canada
        pleaseNOOSpamKa llal@msn.com



        Comment

        • Trevor Best

          #5
          Re: Code a button

          Trevor Best wrote:[color=blue]
          > Grant wrote:
          >[color=green]
          >> Can I add/code a button on my form that will print only the selected
          >> record?[/color][/color]

          Sorry, misread, thought it said "second" record. D'oh!

          Comment

          Working...