-
Hello
hello
my name is Sandeep Chavda and i would like to ask you one question in visual basic programmimg.
This is how it is:
You have a database for e.g a student database in access
and you make a form in vb that has the fields of the database.
and this is what i want to know:
first the fields are empty when form loads
then when you type the student id THE REST OF THE FIELDS
ARE AUTOMATICALLY FILLED.
i dont know how to do this . can you five me the code
may be about "openrecordset" or "get" commands etc.
i dont know about them.
please help me
i need your help
write to me at [email protected]
waititng for your reply
-
Schavda,
Code:
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
Set rs = cn.Execute("Select * FROM Employees WHERE EmployeeID=" & CInt(Val(txtID.Text)))
'fill the box
txtFirstName.Text = rs!FirstName
txtLastName.Text = rs!LastName
txtTitle.Text = rs!Title
txtBirthDate.Text = rs!BirthDate
'expand the form
Me.Height = 1788
End Sub
Private Sub Form_Load()
'connection to Northwind database on local machine
Set cn = New ADODB.Connection
With cn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb"
.Open
End With
'set the form size
Me.Width = 3648
Me.Height = 828
End Sub
Regards,
TheBao