Click to See Complete Forum and Search --> : ADODC and Adding/Deleting/Searching


February 10th, 2000, 06:41 AM
Hi,
I've just started looking into using ADODC, and tried creating an application of very few lines just to get the concepts of adding, deleting, and searching for records in VB6 using ADODC against an MS Access 97 DB.

However, I'm a bit lost:
- when I add a record, I can not delete it before I have actually exited and
restarted the application (moving to another record and back doesn't help)
- When trying to search, the FindFirst method is not available

All code I use:
--00--
Private Sub CmdAdd_Click()
Adodc1.Recordset.AddNew
Me.TxtName.SetFocus
End Sub
--
Private Sub CmdDelete_Click()
With Adodc1.Recordset
.Delete
.MoveFirst
End With
End Sub
--
Private Sub CmdFind_Click()
Dim Dummy As String
Dummy = "*" & FrmDatabase.TxtSearch.Text & "*"
Adodc1.Recordset.Find "Name Like '" & Dummy & "'"
End Sub
--00--

Basically I think I need a way to update the DB when adding a record, so that I can delete it without restarting the app. Also, I'm following an MSCD book, and the FindFirst method is used for searching. Why is it not available to me? Last question, I'm trying to use "if not .EOF then..." -> However, when I click to navigate to the last record, I am not at EOF until I go to the next record which is blank. Why?

Any help appreciated :o) /Kim (kimb@gofree.indigo.ie)

Weasel
February 10th, 2000, 07:43 AM
Among other things, following a call to .AddNew or .Modify, you must call .Update
ie
Private Sub CmdAdd_Click()
Adodc1.Recordset.AddNew
'line that puts in the data
Adodc1.Recordset.Update

as far as .EOF
While Not RS.EOF
counter = counter + 1
theData(counter) = RS!Name
RS.MoveNext
Wend
generally works
And you'll need more than a .setFocus to actually add data to a record, try something like:
RS("Name") = "Peter"
or
RS!Name = "Peter"
or even
RS(1) = "Peter"
Make sure Name exists and is text 1st.