Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2003
    Posts
    5

    Unanswered: Return value from a query in a textbox

    I am trying to get the return value from a query and place the value in a text box. Can you help me?
    Thanx.

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: Return value from a query in a textbox

    Originally posted by joten
    I am trying to get the return value from a query and place the value in a text box. Can you help me?
    Thanx.
    What does your Query do? Aggrigation?

  3. #3
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Lightbulb rs to textbox

    txtValue.setfocus
    txtValue.text = Rs("Yourval")

  4. #4
    Join Date
    Nov 2003
    Posts
    5
    To hammbakka: it´s a select query


    To Marvels:
    In
    txtValue.setfocus
    txtValue.text = Rs("Yourval")

    What does "yourval" means?

    Thanx

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by joten
    To hammbakka: it´s a select query


    To Marvels:
    In
    txtValue.setfocus
    txtValue.text = Rs("Yourval")

    What does "yourval" means?

    Thanx
    Does your Query return only and always one record so that you want to put the result on the form?

    I use always a CratingTableQuery then I have my result in a table, then you can go through the table using a RecordSet and put your result on the form something like that:
    Me.txt1= rs("myFirstField")

    where rs is a record set containing your table (Resulting from the a CratingTableQuery )

  6. #6
    Join Date
    Nov 2003
    Posts
    5
    - Does your Query return only and always one record so that you want to put the result on the form?

    Yes, only and always one record is returned.

    - About your answer, can you tell me the whole code I have to writte in order to place the value in the textbox?

    Thank you in advance.

  7. #7
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Cool code

    private sub


    ......

    openRs...........("SELECt * FROM x .......")



    Me.txt1.setfocus
    Me.txt1= rs("myFirstField")



    exit sub


    PS. Yourval means = your value

  8. #8
    Join Date
    Nov 2003
    Posts
    5
    Sorry, but I'm a beginner and I'd need the whole code. Is it possible?

  9. #9
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    Originally posted by hammbakka
    Does your Query return only and always one record so that you want to put the result on the form?

    I use always a CratingTableQuery then I have my result in a table, then you can go through the table using a RecordSet and put your result on the form something like that:
    Me.txt1= rs("myFirstField")

    where rs is a record set containing your table (Resulting from the a CratingTableQuery )
    1. Convert your query to TableCreating Query. Let the table be T_Results for example

    2. In the form_Open event you can write thís code:
    Dim db as Database
    Dim rs as RecordSet, sq as string

    sq="SELECT * FROM T_Results"
    set db= currentDB
    Set rs=db.open(sq, dbOpenDynaset)
    rs.MoveLast
    yourTextBox1= rs("SuitableField")
    yourTextBox2= rs("anotherField")
    rs.close : db.close
    set rs=nothing : set db=Nothing


  10. #10
    Join Date
    Nov 2003
    Posts
    5
    I attach a BD sample. Is it possible to try with it?

    Thank you in advance and sorry for the inconveniences.
    Attached Files Attached Files

Posting Permissions

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