Hi.
I believe my question is the simple one. I have searched the google
group and the internet for the info but none is directly relevent to my
question.
I just want to create a simple VB program with 4 buttons in which each
button will update a field of an Access Table.
I have tried using the following but i can only do AddNew but not
update:
Private Sub Form_Load()
Data1.DatabaseName = "c:\AMKCar\AMKCar.mdb"
Data1.RecordSource = "select * from AMKCar order by Number"
End Sub
Private Sub cmdButton1_Click()
'add a new entry to our table.
With Data1.Recordset
.AddNew
!Item1 = 1
!Item2 = 2
!Item3 = 3
.Update
End With
Data1.Refresh
End Sub
I want to update field of different records based on the different
buttons clicked. For example, if i click button1, field "Item1" will be
updated to 1. If i click button2, field "item2" will be updated to 1.
How can i do that?
Ralph - 25 Jan 2007 13:34 GMT
> Hi.
>
[quoted text clipped - 32 lines]
>
> How can i do that?
comment out the line ...
' .AddNew
-ralph
Norm Cook - 26 Jan 2007 16:44 GMT
> > Hi.
> >
[quoted text clipped - 37 lines]
>
> -ralph
Or change it to read
.Edit
knsharma - 29 Jan 2007 19:36 GMT
Hi,
I suggest You to write below code:
Private Sub Form_Load()
Data1.DatabaseName = "c:\AMKCar\AMKCar.mdb"
End Sub
Private Sub cmdButton1_Click()
Data1.RecordSource = "select * from AMKCar order by Number"
Data1.Refresh
'add a new entry to our table.
With Data1.Recordset
.AddNew
!Item1 = 1
.Update
End With
End Sub
Private Sub cmdButton2_Click()
Data1.RecordSource = "select * from AMKCar order by Number"
Data1.Refresh
'add a new entry to our table.
With Data1.Recordset
.AddNew
!Item2 = 2
.Update
End With
End Sub
Private Sub cmdButton3_Click()
Data1.RecordSource = "select * from AMKCar order by Number"
Data1.Refresh
'add a new entry to our table.
With Data1.Recordset
.AddNew
!Item3 = 3
.Update
End With
End Sub
Thanks,
KNSharma
> Hi.
>
[quoted text clipped - 32 lines]
>
> How can i do that?