Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specified row cannot be located when adding child record (Adodc)

Status
Not open for further replies.

MikeCox

Programmer
Jun 4, 2001
340
US
Hi. I have a situation where users typically add a new parent record, and then associated child records immediately afterward. I've found that if I don't refresh the main (parent) recordset, I get the above error when they try to add a child record. So I created a public sub in the main form to which I've delegeted the refresh operation, and the add-record form calls this sub after validating the new record info. Here's an example of my code:

'in frmMain:
'Adodc1.CommandType = adCmdText
'Adodc1.RecordSource = "SELECT * FROM tblSiteInfo ORDER BY CLLICode

Public Sub RefreshRecordset(SiteID as String)
Adodc1.Refresh
'Refresh sets recordset position to first record, so find the record they just added for user's convenience:
Adodc1.Recordset.Find "SiteID = '" & SiteID & "' ", , adSearchForward, 1
End Sub

'in frmAddRecord:
'after validation:
frmMain.txtFields(0).Text = SiteID
frmMain.Adodc1.Recordset.Update
frmMain.RefreshRecordset SiteID

The frustrating thing about this is after adding a new record, the Adodc doesn't find the new SiteID, like it was never added. But if I refresh the recordset again, it's there. And when I add breakpoints and run in debug mode, it works every time! (that seems to happen to me a lot) Does anyone see what I may be doing wrong? Thanks!

 
I can't understand, what the Adodc is? I heard about Adodb. John Fill
1c.bmp


ivfmd@mail.md
 
It's the ADO Data Control, the ActiveX equivelant of the Data1 control from VB3. The Recordset object exposed by the Adodc is an ADODB.Recordset. Does that make sense?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top