VB6 Databound text boxes cease to coordinate with datagrid control



Data from an Access database in my app fills a record set and this recordset
is the data source to multiple text boxes, and a datagird. It worked fine,
with text box values changing in synchronization with changes in the selected
row in the datagrid. Also, entries in the text box were automatically shown
in the corresponding grid dell. Then, suddenly, the text boxes display
nothing, while the data grid continues to work OK. I have reinstalled the
MS Access database and VB, supposing that the work software had become
corrupted.
I have coded a tiny demo app to show the problem after the ====== line below.
Thank you for kind help. Lamont

Step 1. Create recordset from the database. This works and fills recordset
with data.

Step 2. Set the record set as datasource for a data grid. This works &
fills grid.

dgMsg.ClearFields 'dbMsg is the data bound
data grid.
Set dgMsg.DataSource = rsVotersLocal

Step 3. Set textboxes' data source from the recordset
Set txtVoterID.DataSource = rsVotersLocal ' txtVoterID, txtFirstName
etc. are the text boxes
Set txtVoterID.DataSource = rsVotersLocal
Set txtFirstName.DataSource = rsVotersLocal
Code for demo app==================================
Private strCnn As String
Private cnnVotersLocal As ADODB.Connection
Private rsVotersLocal As ADODB.Recordset
Private Sub Form_Load()
strCnn = "Provider = Microsoft.jet.OLEDB.4.0;Data Source=" & App.Path &
"\Demo.mdb"
Set cnnVotersLocal = New ADODB.Connection
cnnVotersLocal.Open (strCnn)
Set rsVotersLocal = New ADODB.Recordset
Dim strSQL As String
strSQL = "Select voterid, firstname, lastname from voterslocal order by
lastname, firstname;"
With rsVotersLocal
.ActiveConnection = cnnVotersLocal
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Properties("IRowsetIdentity") = True
.Open strSQL, , , , adCmdText
End With
dgMsg.ClearFields
Set dgMsg.DataSource = rsVotersLocal
Set txtVoterID.DataSource = rsVotersLocal 'Textbox
Set txtFirstName.DataSource = rsVotersLocal 'Textbox
Set txtLastName.DataSource = rsVotersLocal 'Textbox
End Sub

'No Code after form load. Just type in text boxes and select rows in the
grid.

--
Lamont Phemister
.



Relevant Pages

  • RE: Filling in form with recordset HELP
    ... >> which i am filling out a form to then put data in an access database. ... >> (recordset) to appear in all the text boxes on my form. ... >> text box with a query button. ...
    (microsoft.public.access.formscoding)
  • Re: need similar solution to "cascading combos"...
    ... That's not quite the same as setting it to a recordset, but the values are, ... I learned from Delphi programming that if I sniff around, ... > I'm creating a search form w/ unbound combo boxes ... Also "Filter" is a very specific term in Access, ...
    (microsoft.public.access.forms)
  • RE: need similar solution to "cascading combos"...
    ... if there were some way to use the subForm recordset in my ... boxes, I used several unbound combo boxes for Customer Name, Product Name, ... there's no filter applied. ...
    (microsoft.public.access.forms)
  • ADO - recordset navigation with code
    ... behind an unbound form containing unbound text boxes. ... I have set up buttons on my unbound form for MoveNext, ... With ADO code alone, how do I mimic the action ... appearence of moving back and forth through the recordset, ...
    (microsoft.public.access.formscoding)
  • Re: pivot table
    ... The first column text boxes have the names of: ... Dim rs As DAO.Recordset ... >> I guess I would create an unbound form that code fills from a recordset. ...
    (microsoft.public.access.queries)