0

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.

2
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by varun.coolmax
0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.