Results 1 to 5 of 5

Thread: Stupid Question... Sql and a text box...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Location
    Allen, Texas
    Posts
    125

    Stupid Question... Sql and a text box...

    Ok, I have a report in access that I am adding a text field to.

    I have a select statement that returns one value.

    I want that select statement to put the value into the text box.

    I have been going crazy today figuring it out. All I get is #NAME?

    Here is what the source is.

    = (Select Top 1 NumAdj From TblName) Thats all. Once I get that to return something, Then I can add a where clause.

    Thanks.

  2. #2
    Junior Member llkhoutx's Avatar
    Join Date
    Jan 2005
    Location
    Houston, TX
    Posts
    19

    Re: Stupid Question... Sql and a text box...

    = (Select Top 1 NumAdj From TblName)
    is not proper VBA syntax fror a textbox ControlSource.

    Try

    ="Select Top 1 NumAdj From TblName"

    Alternatively, TblName is mispelled, or "NumAdj" is not a field in "TblName."

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Location
    Allen, Texas
    Posts
    125

    Re: Stupid Question... Sql and a text box...

    I guess this is more of an Access question than a VBA question. I am trying to get the sql statement in using the front in. (Properties Window) Anyone know if that is possible.


    Quote Originally Posted by llkhoutx
    is not proper VBA syntax fror a textbox ControlSource.

    Try

    ="Select Top 1 NumAdj From TblName"

    Alternatively, TblName is mispelled, or "NumAdj" is not a field in "TblName."

  4. #4
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Stupid Question... Sql and a text box...

    Quote Originally Posted by wookie224
    I guess this is more of an Access question than a VBA question. I am trying to get the sql statement in using the front in. (Properties Window) Anyone know if that is possible.
    What does that mean? You could create the query in the query section of the database and set the control source to that.
    Tengo mas preguntas que contestas

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

    Re: Stupid Question... Sql and a text box...

    For a report, you can only have one recordsource. From that recordsource
    you can map textboxes to the rs' fields. You can not execute a select
    statement on a report.

    Is seems like you can do one of two things:
    1. Modify your reports reportsource to include the field you need by modifing
      the query.
    2. Add a sub-report with the sql statement as its recordsource and the
      subform will have the textbox mapped to the field you need.

    HTH
    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