Results 1 to 8 of 8
  1. #1
    jasonbarnes is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2010
    Location
    NC
    Posts
    56

    Where do I put a string I want to flow to a textbox?

    I am trying to set a string to show up in a textbox.



    I DIMed the string as

    Public Sub Tons()

    Dim SumofBusTEUS As String

    SumofBusTEUS = "SELECT Sum(tblTestData.SumOfTEUS) AS SumOfSumOfTEUS " _
    & " FROM tblTestData WHERE (((([tblTestData].[#BUSRULE])) Is Not Null)) "

    End Sub


    Then in the control source to the textbox I did

    =(SumofBusTEUS)


    What I am missing causing this not to work??

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You have to open up a recordset based on the query. An easier way might be to use the DSum() domain aggregate function to populate your control.


    DSum("sumOfTEUS","tblTestData","tblTestdata.[#BUSRULE] is not null")

  3. #3
    jasonbarnes is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2010
    Location
    NC
    Posts
    56
    Wow. Much easier to accomplish this task. If I can only apply the same method to the other things I want to display.

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    If the values are in the same table, you can use a form to display the info. If you want to display data from another table, the domain aggregate functions can help (DLookup(), DSum(), DMin(), DMax() etc.)

    I probably use DLookup() the most.

  5. #5
    jasonbarnes is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2010
    Location
    NC
    Posts
    56
    Can you help me with the proper syntax for DCount?

    Thought it would be...

    =DCount("NAMEFUNCTION","tblTestData","tblTestData.[NAMEFUNCTION]="ORDER""]

    This should reflect a count of the field NAMEFUNCTION in tblTestData that is equal to ORDER. I think my problem centers around not having to use NAMEFUNCTION in the expr area. Or possibly not having to do "" around ORDER in the criteria. I've played around with it quite a bit. Maybe I'm missing something.

  6. #6
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Since the DCount() only counts records, a field is not normally specifed; also you were using a square bracket rather than an ending parenthesis. Also if order is a fixed value (rather than a variable), you can include the whole section in double quotes. This should be the correct syntax for counting all records whose namefunction is equal to the worde order.

    DCount("*","tblTestData","tblTestData.[NAMEFUNCTION]=ORDER")

  7. #7
    jasonbarnes is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2010
    Location
    NC
    Posts
    56
    Thanks again!

  8. #8
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome.

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

Similar Threads

  1. Setting SQL = string
    By jasonbarnes in forum Programming
    Replies: 7
    Last Post: 02-18-2011, 11:02 AM
  2. Using a string to DIM a Recordset
    By ColPat in forum Programming
    Replies: 10
    Last Post: 09-25-2010, 03:53 PM
  3. Making report flow horizontally
    By Scaffold in forum Access
    Replies: 12
    Last Post: 07-21-2010, 01:43 AM
  4. String Matching
    By tuna in forum Programming
    Replies: 1
    Last Post: 05-16-2010, 12:22 PM
  5. Text flow
    By JudgeJudi in forum Database Design
    Replies: 1
    Last Post: 10-28-2009, 09:23 PM

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