General discussion

Locked

updating database

By csaha ·
Private Sub cmdNext_Click()
With mRSGrades
.MoveNext
If Len(frmGrades.txtClassID.Text) = 10 Then
frmGrades.txtCourseID.Text = Left$(frmGrades.txtClassID.Text, 7)
ElseIf Len(frmGrades.txtClassID.Text) = 9 Then
frmGrades.txtCourseID.Text = Left$(frmGrades.txtClassID.Text, 6)
ElseIf Len(frmGrades.txtClassID.Text) = 7 Then
frmGrades.txtCourseID.Text = Left$(frmGrades.txtClassID.Text, 4)
End If

If .EOF Then .MoveLast
End With
Private Sub Form_Initialize()
Set mRSGrades = deGraduation.rscdGrades

'============ GS
If Len(frmGrades.txtClassID.Text) = 10 Then
frmGrades.txtCourseID.Text = Left$(frmGrades.txtClassID.Text, 7)
ElseIf Len(frmGrades.txtClassID.Text) = 9 Then
frmGrades.txtCourseID.Text = Left$(frmGrades.txtClassID.Text, 6)
ElseIf Len(frmGrades.txtClassID.Text) = 7 Then
frmGrades.txtCourseID.Text = Left$(frmGrades.txtClassID.Text, 4)
End If
This code works but I need to click the next button so can you haelp me with recordset setup.
Thanks
Chitra Saha

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

updating database

by Bill_H In reply to updating database

Pursuant to our e-mail discussions (updating all records with a single button click)...

Change the code in the cmdNext_Click subroutine to the following:

Private Sub cmdNext_Click()
With mRSGrades
.MoveFirst
While Not .EOF If Len(frmGrades.txtClassID.Text) = 10 Then
frmGrades.txtCourseID.Text = Left$(frmGrades.txtClassID.Text, 7)
ElseIf Len(frmGrades.txtClassID.Text) = 9 Then
frmGrades.txtCourseID.Text = Left$(frmGrades.txtClassID.Text, 6)
ElseIf Len(frmGrades.txtClassID.Text) = 7 Then
frmGrades.txtCourseID.Text = Left$(frmGrades.txtClassID.Text, 4)
End If
.MoveNext
Wend
End With
End Sub

Collapse -

updating database

by Bill_H In reply to updating database

Oops...forgot to extract the data!

----------Option 1 -----------------
If you want to set the text field, insert the following line *after* the 'While Not .EOF':

frmGrades.txtClassID.Text = .Fields("ClassID").Value

(Replace the "ClassID" value with the actual name in the database, of course).

Following the code that manipulates the value in frmGrades.txtClassID.Text, enter the following 3 lines:

.Edit
.Fields("ClassID").Value = frmGrades.txtClassID.Text
.Update

(Again, replacing the "ClassID" value with the actual name in the database...)

----------Option 2 -----------------
If you don't want to update the text field, place the following line after "While Not .EOF":

.Edit

Then replace all occurrences of
'frmGrades.txtClassID.Text' with '.Fields("ClassID").Value'.

Insert the following line *before* '.MoveNext':

.Update

Probably clear as mud...e-mail me if you have any questions.

Collapse -

updating database

by csaha In reply to updating database

Thanks for all that information. It works like a charm. Friday I worked till 3a.m in the morning trying out different aspects of this project. But I was kind of stuck here. Thanks a bunch.

Collapse -

updating database

by csaha In reply to updating database

This question was closed by the author

Back to Web Development Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums