hello guys and happy new year!~

let me be the first to ask a question this 2015.. huehue

is it possible to start with the same recordset when going to the next form?

i have a textbox for name in form1 when i go to form2 i want to display in the label his address.

sample database
name-------address
abc--------123
def--------456
ghi--------789

let's say im on recordset 2.. i type on my textbox "def"
then go to next form and the label should display "456"

my code is missing something

Private Sub Command1_Click()
    Adodc1.Refresh
    Do Until Adodc1.Recordset.EOF
        If Adodc1.Recordset.Fields("name") = Text1.Text Then
            [missing code]
            Form2.Show
            Exit Sub
        Else
            Adodc1.Recordset.MoveNext
        End If
        Exit Sub
    Loop
End Sub

or if you can suggest other code..

thanks!~

Recommended Answers

All 2 Replies

You can do it. Your codes are quite correct.
But, why are you going through a loop? It will slow down your process.
Use FindFirst method to get quick result.

i'm not yet familiar with findfirst.. the code above that i used is the one that i find in a vb tutorial site.. the tutorial is about login using adodc Click Here
im trying to apply it on my own example by doing some trial and error

anyways.. i figured it out.. my coding is a bit limited cause im still learning so pardon my "clumsiness"

Form1

Private Sub Command1_Click
    Adodc1.Refresh
    Do Until Adodc1.Recordset.EOF
        If Adodc1.Recordset.Fields("name") = Text1.Text Then
            Form2.Text1.Text = Adodc1.Recordset.Fields("address")
            Form2.Show
            Exit Sub
        Else
            Adodc1.Recordset.MoveNext
        End If
    Loop
End Sub

Form2

Private Sub Command1_Click()
    Form1.Adodc1.Recordset.Fields("address") = Text1.Text
    Form1.Adodc1.Recordset.Update
    Form1.Adodc1.Refresh
    Form1.Adodc1.Refresh
End Sub

i always do double refresh because sometime with one refresh, it doesnt refresh my record~

now i can apply it on a bigger system that i'm doing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.