Page 1 of 3 123 LastLast
Results 1 to 15 of 36
  1. #1
    Join Date
    Mar 2007
    Posts
    91

    Unanswered: Reading off a table and displaying the result in a textbox

    Hi guys.

    Wheneva i load a certain screen i wanna read off a table and display the results in textbox (preferably a lable but it seems like that's not allowed - i know in VB6 it's possible)

    Curently i use queries to do that, i append my data to some temp tables then send it to the original tables. I not longer wanna do that as it takes too much time.

    Pls help

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Why don't you write an SQL query and use it as the textbox' control source?
    George
    Home | Blog

  3. #3
    Join Date
    Mar 2007
    Posts
    91
    i've tried that but the text box just displays the code i've written else if i put val infront it displays 0 regardless of the results

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    It often helps if you post the code you have written.
    You might need a simple equals sign followed by a quote (") then your sql statement closed with a final quote (").
    George
    Home | Blog

  5. #5
    Join Date
    Mar 2007
    Posts
    91
    here's ma code:

    "SELECT [dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)].UnitSales FROM [dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)] WHERE ((([dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)].Vendor)='2RED02 ~ RED BULL - STOCK'))FROM [dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)] WHERE ((([dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)].Vendor)='2RED02 ~ RED BULL - STOCK')) and (([dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)].Customercode)= [forms]![molo]![customercode])"

    Thanks

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    First thing I notice is the lack of an equals sign at the beginning - did you try that?

    Secondly, is the "molo" form open when running this? It'll need to be..
    George
    Home | Blog

  7. #7
    Join Date
    Mar 2007
    Posts
    91
    molo is the current form (form where the text box is)
    if i use = it displays the code as it is

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Use and equals and remove the quotes.

    Come on boyo, let's at least try put some effort in
    George
    Home | Blog

  9. #9
    Join Date
    Mar 2007
    Posts
    91
    When i take out the quotes i get an errror msg sayin "the syntax of the subquery in this expression is incorrect"
    "Check the subquery's syntax and enclose it in parenthesis"

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Why am I debugging a statement you can read through.
    It has already told you that you have a subquery, I can see that. You know how?

    The word FROM appears twice.
    First thing you should do is TIDY UP the query into a READABLE format so you can then SEE the mistake.
    Here, I'll start you off
    Code:
    SELECT [dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)].UnitSales
    FROM [dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)]
    WHERE ...
    Put some effort in lad.
    EDIT: I'm happy to HELP you but I am NOT going to do this for you.
    George
    Home | Blog

  11. #11
    Join Date
    Mar 2007
    Posts
    91
    Oops sorry bout that 1. I've cleaned it up, but it's still complainin about the same thing.

    The only reason i hand't cleaned it up was coz i was copying straight from the source code field (i know dat's no excuse)

  12. #12
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    TIDY UP the query as per my example and post it please.
    George
    Home | Blog

  13. #13
    Join Date
    Mar 2007
    Posts
    91
    Here's ma code

    ="SELECT [dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)].UnitSales
    FROM [dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)]
    WHERE (((([dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)].Vendor)='2RED02 ~ RED BULL - STOCK'))
    AND (([dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)].Customercode)= [forms]![molo]![customercode]))"

    Thanks

  14. #14
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    *tidies it up some more*
    Code:
    SELECT UnitSales 
    FROM [dbo_LSV_DW_JMC Sales (Cust-Vendor-MTD)] 
    WHERE Vendor = '2RED02 ~ RED BULL - STOCK'  
    AND Customercode = [forms]![molo]![customercode]
    Now we have tidied it up, let's run some tests...
    Firstly, we're wanting the result to show in a textbox - how many results do you think a textbox can show?
    When you run this query, how many results do we return?

    In the textbox try all these different examples:
    Code:
    =" SQLStatement "
    = SQLStatement
    " SQLStatement "
     SQLStatement
    George
    Home | Blog

  15. #15
    Join Date
    Mar 2007
    Posts
    91
    I only want 1 result (that's y i chose a textbox and not a combobox)
    Thanks i'll try these

Posting Permissions

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