I need some help with displaying Database information. I am just learning
to use VB with databases. I have a datagrid that is populated via
code.
Dim sSQL As String
Set objAccessConnection = New ADODB.Connection
objAccessConnection.CursorLocation = adUseClient
objAccessConnection.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=c:\test\lesson6\custlist.mdb;"
sSQL = "select * from cust"
Set rsAccess = New ADODB.Recordset
rsAccess.Open sSQL, objAccessConnection, adOpenKeyset, adLockOptimistic
Set grdLedger.DataSource = rsAccess
''Works fine
I also have a command button users can click to find a record. When clicked
an input box is used to gather the search critria. I then want to
be able to pop up a hidden frame showing the resulting record. The search works, it moves to
the named record in the datagrid, but I want all fields
in textboxes (I don't know how to link the textboxes to the database
via code). I need the user to be able to edit the found file. Eventually I want to
get rid of the datagrid, but just learning, I am using it as most examples use some
type of grid. Here is the command button code.
Private Sub cmdEdit_Click()
Dim stClient As String
stClient = InputBox("Enter Client Number", "Edit Client"
If stClient <> "" Then
With rsAccess
.MoveFirst
.Find "Client='" & stClient & "'", , , 0
End With
Else
MsgBox "No Client Number entered"
Exit Sub
End If
''Need to set found records into the text boxes
'txtClient.....
'txtPass......
'txtComm......
Frame1.Visible = True
End Sub
Thanks in advance for any help.
Catrina
to use VB with databases. I have a datagrid that is populated via
code.
Dim sSQL As String
Set objAccessConnection = New ADODB.Connection
objAccessConnection.CursorLocation = adUseClient
objAccessConnection.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=c:\test\lesson6\custlist.mdb;"
sSQL = "select * from cust"
Set rsAccess = New ADODB.Recordset
rsAccess.Open sSQL, objAccessConnection, adOpenKeyset, adLockOptimistic
Set grdLedger.DataSource = rsAccess
''Works fine
I also have a command button users can click to find a record. When clicked
an input box is used to gather the search critria. I then want to
be able to pop up a hidden frame showing the resulting record. The search works, it moves to
the named record in the datagrid, but I want all fields
in textboxes (I don't know how to link the textboxes to the database
via code). I need the user to be able to edit the found file. Eventually I want to
get rid of the datagrid, but just learning, I am using it as most examples use some
type of grid. Here is the command button code.
Private Sub cmdEdit_Click()
Dim stClient As String
stClient = InputBox("Enter Client Number", "Edit Client"
If stClient <> "" Then
With rsAccess
.MoveFirst
.Find "Client='" & stClient & "'", , , 0
End With
Else
MsgBox "No Client Number entered"
Exit Sub
End If
''Need to set found records into the text boxes
'txtClient.....
'txtPass......
'txtComm......
Frame1.Visible = True
End Sub
Thanks in advance for any help.
Catrina