Results 1 to 4 of 4

Thread: desperate and helpless!!!...please help

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    103

    Angry

    i want to use a control that can display certain
    data from my sql7 server
    my SQL query is
    "select firstname,surname,details from people where
    personid =" & personvariable

    i want it to display the firstname and surname,details
    using a control that is dependant on my variable called personid
    ie
    so if i have a listbox control with 100 names and surnames
    in it and i select one persons name it picks up my varible assigned to that person called personvariable and assignes that value to my personID which is used to pick up all the information a on that person and display it in my control
    ie datacontrol until i select another person!!!
    help me please
    i have tried using a datagrid control with a data control
    but my query stuffs it up cause it does not pick up my variable!!!

    please respond ASAP im having real difficultys to get this going!!


  2. #2
    Guest
    maybe you should submit all relevant code.

    best regards

    Sascha

  3. #3
    Lively Member
    Join Date
    Aug 2000
    Posts
    125
    "select firstname,surname,details " & _
    "from people where personid ='" & personvariable & "'"

  4. #4
    Lively Member iataman's Avatar
    Join Date
    Jun 2000
    Location
    Turkey
    Posts
    71

    Wink

    You can use Commands in an ADO object. After you add a 'Connection' to your 'Data Enviroment', you add a 'Command' to your connection. Right click on the Command object and select properties. In 'SQL Statement' textbox enter your query like "SELECT firstname, lastname FROM ...".
    Drag the command object on to your form and all controls will be added automatically. (you can remove if you have things that you don't want users to see, like ID etc.)
    You can use the MoveNext, MovePrevious and Move methods of your command. If you want better control on your project, you can try loading your 'name data' in a listbox through a query and updating the data according to the ListIndex, selected at runtime.

    I mean sth. like this:

    Private Qry as String
    Private RecSet as Recordset

    Private Sub Form_Load()
    ' Where "DE" is the name of your ADO Data Enviroment
    Qry = "SELECT DISTINCT firstname, surname FROM people ORDER BY surname"
    Set RecSet = DE.Con.Execute(Qry)
    For i=1 to RecSet.RecordCount
    List1.AddItem RecSet.Fields(1)+", "+RecSet.Fields(0)
    RecSet.MoveNext
    Next
    End Sub

    Private Sub List1_Click()
    Dim Name, FName, LName as String
    If List1.ListIndex > -1 Then ' Be sure sth. is selected
    ' Option 1
    Name = List1.List(List1.ListIndex)
    FName = Mid(Name ,1, InStr(1,Name,",")-1)
    LName = Mid(Name , InStr(1,Name,",") + 2)
    Qry = "SELECT details FROM people WHERE firstname = '"+fname+"' AND surname = '"+LName+"'"
    Set RecSet = DE.Con.Execute(Qry)
    Text1 = RecSet.Fields(0)
    Text2 = RecSet.Fields(1)
    .... = ....
    .... = ....
    End If

    End Sub

    I hope some of these helps.

    While YourAge<=40
    Live(YourLife)
    Wend

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