Results 1 to 4 of 4

Thread: Easy DB question.....

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 1999
    Location
    J-ville, NC
    Posts
    54

    Post

    Alright, I'm accessing a db though ADO. I have a textbox that sends a query search for whatever's in that textbox

    Code:
    Private Sub txtPhone_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    adoCustomer.RecordSource = "SELECT * FROM Customers" & _ "WHERE [Phone Number] = '" & txtPhone.Text & "'"
    ' txtFname.Text = adoCustomer.Recordset![First Name]
    End If
    End Sub
    Now how would I display those fields in designated textboxes??
    David Underwood
    Cannabatech Corporation

    ICQ - 14028049
    E-mail - [email protected]

    AIM - DK4ever23[/b]


  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    India
    Posts
    298

    Question is this what u wanted??????

    Hi,

    firstly,

    what's the problem with the line

    ' txtFname.Text = adoCustomer.Recordset![First Name]

    in ur code??? Is that not working????

    coz as far as I can see....that should work. U'll probably have to repeat that line for each textbox.

    Maybe u can also try using a control array (for the textbox), so that u can put that one line of code in a loop.

    Hope this helps.

  3. #3
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    I don't use the ADO control ( I prefer to use the Recordset objects etc) but I think you'll need to do

    ADOCustomer.Refresh

    before you do

    txtFname.Text = adoCustomer.Recordset![First Name]


    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb Open Recordset

    Hope this can help you.

    Code:
    Option Explicit
    Dim Conn As New ADODB.Connection
    Dim Rs As New ADODB.Recordset
    Dim xSQL As String
    Private Sub Form_Load()
    'Let take Biblio.mdb as an example
    'Establish the Connection
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\Biblio.mdb"
    xSQL = "SELECT * FROM Authors WHERE Au_ID < 1000 ORDER BY Au_ID ASC;"
    With Rs
        .Open xSQL, Conn, adOpenKeyset, adLockPessimistic
        While Not .EOF
            Text1.Text = Text1.Text & .Fields(0) & Space(10) & .Fields(1) & vbCrLf
            .MoveNext
        Wend
    End With
    Rs.Close
    Set Rs = Nothing
    Conn.Close
    Set Conn = Nothing
    End Sub

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