This loop is not working - need help

joltremari

Registered User.
Local time
Today, 20:17
Joined
Jun 4, 2001
Messages
24
When I tried this code to loop through the records to clear the data, it added about 3,700 records to the table, now I don't know how I'm going to get all those records out, but more importantly I don't not know why this code is not working. If someone could take a look at it and maybe figure out why it did wrong I would greatly appreciate it.



Code:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String

strSQL = "SELECT * FROM 2006TalentShow"

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)

Do Until rst.EOF = True
'On Error GoTo Err
Forms![frm2006TalentShow]![TypeActAdult] = ""
Forms![frm2006TalentShow]![curTypeAct] = ""
Forms![frm2006TalentShow]![TypeActGospelYouth] = ""
Forms![frm2006TalentShow]![TypeActGospelAdult] = ""
Forms![frm2006TalentShow]![curEntered] = ""
Forms![frm2006TalentShow]![Payment] = ""
Forms![frm2006TalentShow]![curYouth] = ""
Forms![frm2006TalentShow]![curAdult] = ""
Forms![frm2006TalentShow]![curGospel] = ""
Forms![frm2006TalentShow]![curGospelYouth] = ""
    NextRecord_Click       'clickevent of next record button
Loop


Set rst = Nothing
Set dbs = Nothing

End Sub
 
You can't delete records by setting them equal to an empty string. Create a Delete query and call it. Also, given that you have frm2006TalentShow as your form name it makes me think that you don't have your database designed well as you shouldn't be doing specific things for each year. You should be able to just continue to add data for each year (in the same tables, and then you can pull data by year that you need).
 

Users who are viewing this thread

Back
Top Bottom