Results 1 to 3 of 3

Thread: Pass values from a Access form to a report

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Posts
    25

    Pass values from a Access form to a report

    Hi All,

    I have a simple form in MS Access. It contains a customer ID, name and a command button.

    What I want the command button to do is pass the customer ID to a report and print the customers details according to the customer ID.

    So the user selects a customer ID clicks the command button and the details of the customer according to ID prints.

    Any Thoughts?
    mccreaso

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Pass values from a Access form to a report

    What I want the command button to do is pass the customer ID to a report and print the customers details according to the customer ID.
    1) Simply set the value of the report control in the OnOpen property of the report:

    VB Code:
    1. Report[reportname]: OnOpen
    2. 'lets say the textbox will store the Cust ID
    3. Me![TextBox] = Forms!frm[Formname]![custId]

    You must open the report before closing the form, otherwise the reference will not be valid.

    2) Use Dlookup() for getting the details from the table based on cust ID.

    I haven't tried it yet...

    Hope it helps...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Pass values from a Access form to a report

    Better would be to create a new class and create a read/write property where you can set the value from the form and read it from the report. his will allow the form to be closed or be open still without affecting anything else.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width