R
rblaustein
I am trying to write a VBA procedure to increment an entire table by a
value of 1 when a user clicks on a button of a form (or selects from a
custom menu). The table, called tblStudents contains student ID's,
names, etc. and their grade level (e.g.- 10). The user has requested
for this functionality to be built so that he/she can click the button
at the end of each school year, and thus update the entire table with
the new grade levels. Any ideas on the best way to do this???
This is what I tried thus far, but to no avail...
Private Sub btnUpdateGradeLevel_Click()
Dim RecordQty As Integer
Dim RecordCounter As Integer
DoCmd.OpenTable "tblStudents", acViewNormal, acEdit
RecordQty = DCount("Grade", "tblStudents")
DoCmd.GoToRecord acDataTable, "tblStudents", acFirst
For RecordCounter = 1 To RecordQty
DoCmd.GoToRecord acDataTable, "tblStudents", acGoTo,
RecordCounter
Grade = Grade + 1
Next
DoCmd.Close acTable, "tblStudents", acSaveYes
End Sub
This code only updates the first record - but by the total number of
records in the table. In other words, if John Smith is the first
record of 1000 total records, and he is in grade 10, it updates his
record to be in grade 1010, and none of the other records are changed
at all.
Any help is greatly appreciated!!! Thanks!
value of 1 when a user clicks on a button of a form (or selects from a
custom menu). The table, called tblStudents contains student ID's,
names, etc. and their grade level (e.g.- 10). The user has requested
for this functionality to be built so that he/she can click the button
at the end of each school year, and thus update the entire table with
the new grade levels. Any ideas on the best way to do this???
This is what I tried thus far, but to no avail...
Private Sub btnUpdateGradeLevel_Click()
Dim RecordQty As Integer
Dim RecordCounter As Integer
DoCmd.OpenTable "tblStudents", acViewNormal, acEdit
RecordQty = DCount("Grade", "tblStudents")
DoCmd.GoToRecord acDataTable, "tblStudents", acFirst
For RecordCounter = 1 To RecordQty
DoCmd.GoToRecord acDataTable, "tblStudents", acGoTo,
RecordCounter
Grade = Grade + 1
Next
DoCmd.Close acTable, "tblStudents", acSaveYes
End Sub
This code only updates the first record - but by the total number of
records in the table. In other words, if John Smith is the first
record of 1000 total records, and he is in grade 10, it updates his
record to be in grade 1010, and none of the other records are changed
at all.
Any help is greatly appreciated!!! Thanks!