Edit a table using DAO, PLEASE OPEN

alireza1989@hot

Registered User.
Local time
Yesterday, 20:16
Joined
Feb 26, 2007
Messages
23
Hi, I have a form called Edit Column, which contains two text boxes: ID and Description. The user types something in these two boxes and presses a button, and this button should take the value of ID and edit description for that particular ID in the table "Map". Here is the code I have written for it:
Code:
Dim d As Database
Set d = CurrentDb
Dim r As Recordset
Set r = d.OpenRecordset("Map")

r.MoveFirst
If r![ID] = Me.Text1 Then [I]('Text1 is the text box where the user enters an ID)[/I]
Do While Not r.EOF
r.Edit
r![Description] = Me.Text3
r.Update
r.MoveNext
Loop
MsgBox "Successful", vbInformation
Else
MsgBox "This column does not exist in the Store", vbCritical
End If

Thanx in Advance
 
Have you stepped through your code in debug ?

I think you will find that your code, as written will...
Code:
If the ID number entered matches the ID of the first record in the recordset,
update the description of [B]every[/B] record to the entry in text3.

If the ID number entered doesn't happen to match the ID of the first
record in the recordset, present a "no Column" message.

Knowing that, could you re write your code ?

Alternately, why wouldn't you use a bound form ? The method you are proposing is somewhat cumbersome and inefficient.
 

Users who are viewing this thread

Back
Top Bottom