Results 1 to 10 of 10
  1. #1
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209

    Pass Data From Form To Report


    I have a form, that I want to be able to press a command button and take the data from the form and populate a report with that data. How would I achieve such in access 2000?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    To display the record:

    http://www.baldyweb.com/wherecondition.htm

    or if unbound you can have textboxes on the report refer to textboxes on the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209
    Quote Originally Posted by Juan4412 View Post
    I have a form, that I want to be able to press a command button and take the data from the form and populate a report with that data. How would I achieve such in access 2000?
    I have added this to the OnClick() event handler of a command button I have added to my form -- however, it only shows #Name? for everything?
    Code:
    Private Sub cmdbutton_Click()
    
    
    DoCmd.OpenReport "Report1", acPreview, , "userid = '" & txtuserid & "'"
    
    
    End Sub

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Is userid defined as a Text Datatype, as your code suggests?

    If it's defined as a Number Datatype, the syntax for the Where Condition would be

    "userid = " & Me.txtuserid

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Does the report show data if you open it from the nav pane?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209
    Quote Originally Posted by Missinglinq View Post
    Is userid defined as a Text Datatype, as your code suggests?

    If it's defined as a Number Datatype, the syntax for the Where Condition would be

    "userid = " & Me.txtuserid

    Linq ;0)>
    It's actually a linked SQL Server table that is defined as an autonumber (so yes an int). I altered to your syntax of
    [code]"userid = " & Me.txtuserid{/code] but I get the same outcome of #Name?

  7. #7
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209
    Quote Originally Posted by pbaldy View Post
    Does the report show data if you open it from the nav pane?
    Nav pane? -- I am wanting to only show the data from the userid that is being displayed on the form, so the form shows data, but the second I attempt to generate the report it does not.

    Question - Should the text boxes on my report be bound or unbound? I have them bound to the corresponding SQL server fields, but if I am just transferring data from the access form, should they be unbound?

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    If you're using the method from my link, which gave the syntax for numeric data types, the assumption is that the report is bound to a table or query and textboxes to the appropriate fields in that table or query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209
    Quote Originally Posted by pbaldy View Post
    If you're using the method from my link, which gave the syntax for numeric data types, the assumption is that the report is bound to a table or query and textboxes to the appropriate fields in that table or query.
    Ah, had a typo! Last question and I am all set. Is there a way to pass a value from the form to the report that is not stored in a database?
    For example, pass the value from the form stored in txt123 to a field on the report called txt12

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Like I said, refer to the form:

    =Forms!FormName.TextboxName

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-14-2015, 12:09 PM
  2. Replies: 7
    Last Post: 03-11-2015, 12:48 PM
  3. Replies: 15
    Last Post: 02-20-2014, 06:40 AM
  4. Pass data from one form to another
    By Bruce in forum Forms
    Replies: 16
    Last Post: 02-25-2013, 03:59 PM
  5. Replies: 1
    Last Post: 03-07-2012, 09:00 AM

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