I need help in updating a database in MS access using VB....i need only 8 entrises (rows) in the database...all i need to do is delete all the rows in the database and then add the new data....i am delelting the whole data since the no of new entries(rows) maybe more or less then the previous no of entries(rows ) in the database.. plzz help in this..ASAP

'For delelteing the Rows

If Not rstRecordset.BOF = rstRecordset.EOF Then

For a = rstRecordset.BOF To rstRecordset.EOF



rstRecordset.Delete
rstRecordset.MoveNext


Next a

Else
MsgBox "No Data in database", vbOKOnly

End If

'for updating the rows


For i = 1 To 8 Step 1

If txtAgenda(i).Visible = True Then


If Not txtAgenda(i).Text = "" Then

rstRecordset.AddNew
rstRecordset.Fields(0).Value = i
rstRecordset.Fields(1).Value = txtAgenda(i).Text

End If


End If


Next i

this is all i have till now...this is executed on a button click event.

The simplest code I can muster is:

If rst.Recordset.Recordcount > 0 then
Do While not rst.Recordset.Recordcount = 0
rst.Recordset.Delete
Loop
 
Else
MsgBox "No Data in database."
 
End if
 
For i = 1 to 8 step 1
 
If txtAgenda(i).visible = true AND txtAgenda(i).Text <> "" then
 
rst.Recordset.AddNew
rst.Recordset.Fields(0).value = i
rst.Recordset.Fields(1).value = txtAgenda(i).Text
rst.Recordset.update
 
End if
 
Next i

HEy thanx...thats a neat solution.....THANX ALOT

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.