Page 1 of 4 1234 LastLast
Results 1 to 15 of 53
  1. #1
    kdtrimble is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2015
    Posts
    41

    Using a Form to Print out a label report

    Hello. I was wondering if I am going about this the correct way.

    I imagine using a simple form that allows a user to input a purchase order number. I then want to be able to hit a button and the
    specific data from a report label i made would print out just the data from that PO number. The trouble I am finding is that the report


    prints out the label for all of the PO records, not the selected on. Any ideas?

    Thank you.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe you can use some VBA and open the report using the OpenReport method. This way, you can add WHERE criteria.

    DoCmd.OpenReport "ReportName", , , "MyField=" & Me.FieldName

  3. #3
    kdtrimble is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2015
    Posts
    41
    I kind of tried that. I am not doing something correctly with the form to filter out the record I need. It all works fine except it prints all of the records instead of the one I enter in the TextBox. I do not know how to make that final connection. Thank you.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    instead of the one I enter in the TextBox.
    Not sure what this means. Are you typing a value into an unbound textbox? Can you post the VBA you tried and explain what happened when the VBA executed?

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Not sure I'm understanding your requirement. ??label report report label???
    Are you trying to use a Form and to enter or select a PurchaseOrder,
    then press/click a button (or double click or other) to display the details of that Purchase Order?
    on your screen? as a printed report?
    You may get ideas from this Martin Green tutorial re dynamic report.

    Good luck.

  6. #6
    kdtrimble is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2015
    Posts
    41
    Thank you. This looks like something I can work with. I will let you know soon if this is solved. Cheers.

  7. #7
    kdtrimble is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2015
    Posts
    41
    What I am trying to do is create a simple form in which the user will enter a Purchase Number and then they hit a button that prints out rptReceiptLabel, with just that one selecte Purchase Number record. My code does not seem to work. I tried it with the text box bound to a variable in my database and then unbound but both failed.

    Private Sub cmdApplyFilter_Click()
    Dim strPurchaseNumber As String
    Dim strFilter As String

    If IsNull(Me.cboPurchaseNumber.Value) Then
    strOffice = "Like '*'"
    Else
    strOffice = "='" & Me.cboPurchaseNumber.Value & "'"
    End If
    strFilter = "[PurchaseNumber] " & strPurchaseNumber
    With Reports![rptReceiptLabel]
    .Filter = strFilter
    .FilterOn = True
    End With
    End Sub

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    You should use code tags when posting vba/sql .

    If you highlight the text involved, then click on the # button above the posting area, that text will be tagged automatically in your post.
    Please clarify in English before telling more about the code.

    What is cboPurchaseNumber? Where do its values come form?
    What is [PurchaseNumber]?

    Why did you create, but did not Dim strOffice?

    You could try this (guessing, since there are several things containing "PurchaseNumber" in their names )
    Code:
    strFilter = "[PurchaseNumber] " & strOffice

  9. #9
    kdtrimble is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2015
    Posts
    41
    I guess I really do not know what I am doing here in Access and really appreciate your time.

    I have a report called rptReceiptLabel. I can run that report now and of course it will print out every record in my database. I only want it to print a specific record indicated by the PurchaseNumber entered by the user. (User enters PurchaseNumber 25211. Then hits 'print' and only the record for 25211 prints to rptReceiptLabel.

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Can you post a copy of the database? Remove anything confidential/private. Then zip.

    Have you seen https://msdn.microsoft.com/en-us/lib.../ff835068.aspx
    You could use his sample code(adjusted for your criteria) and see what happens (error message/number, wrong record....)

  11. #11
    kdtrimble is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2015
    Posts
    41
    Click image for larger version. 

Name:	Untitled - 1.jpg 
Views:	28 
Size:	117.2 KB 
ID:	20550Click image for larger version. 

Name:	Untitled - 3.jpg 
Views:	28 
Size:	154.0 KB 
ID:	20551

  12. #12
    kdtrimble is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2015
    Posts
    41
    it's a big database. What specifically do you need to see?

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    PurchaseNumber -- source table design
    and
    All code behind your form.

    Looks like you're running a SQL server backend??

  14. #14
    kdtrimble is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2015
    Posts
    41
    yes SQL 8. I have the report working except for it pulls all of the records no the one i want the form to filter.

  15. #15
    kdtrimble is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2015
    Posts
    41
    Click image for larger version. 

Name:	Untitled - 1.jpg 
Views:	27 
Size:	127.9 KB 
ID:	20553 Not sure if this is what you wanted.

Page 1 of 4 1234 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 02-21-2015, 11:35 PM
  2. Replies: 2
    Last Post: 02-07-2015, 04:30 PM
  3. Replies: 14
    Last Post: 01-08-2015, 04:50 PM
  4. Print single label
    By Voodeux2014 in forum Access
    Replies: 2
    Last Post: 11-12-2014, 01:52 PM
  5. Print Label when certian condition is met.
    By talktime in forum Reports
    Replies: 3
    Last Post: 12-15-2012, 03:26 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums