Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / January 2007



Tip: Looking for answers? Try searching our database.

Using Ms Access with VB 6.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NewBie - 25 Jan 2007 13:13 GMT
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?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.