Download presentation
Presentation is loading. Please wait.
Published byCornelia Kelly Modified over 8 years ago
1
Using a Database Access97 Please use speaker notes for additional information!
2
donor.mdb
3
VB form
4
Connect contains Access so it does not have to be reset, for another database it would.
5
VB form
6
Text boxes
8
Output
9
Change Before change After change
10
PrDonor1.vbp The click events are programmed to move through the Recordset called datDonor as using methods as coded above.
11
PrDonor1.vbp Visible set to False for datDonor so the data control does not appear on the form.
12
PrDonor2.vbp Private Sub cmdChangeCity_Click() datDonor.Recordset.Edit datDonor.Recordset.Fields("City").Value = txtChangeCity datDonor.Recordset.Update End Sub Before After
13
PrDonor3.vbp
14
Private Sub cmdAdd_Click() datDonor.Recordset.AddNew End Sub The record is added at the end of the table, but when we next view the table it is in order by Idno because Idno is the index or primary key.
15
PrDonor3.vbp Idno is the index or primary key so when we view the donor table, it is in order by index or primary key.
16
PrDonor3.vbp I clicked the delete record button. As you can see the record is no longer on the table. Private Sub cmdDelete_Click() datDonor.Recordset.Delete End Sub
17
PrDonor3.vbp
18
PrDonor4.vbp Find Id results in the input box where the user can enter the id number of the record they want to locate.
19
PrDonor4.vbp I have keyed in the city that I want to find in Data To Find. When I click Find City, it will move to that record.
20
PrDonor4.vbp
21
PrDonor5.vbp
22
When Find City is clicked, the program looks for a match to the city entered in the city text box and displays the information from that record.
23
PrDonor5.vbp Dim wkFoundInd As String Private Sub cmdExit_Click() End End Sub Private Sub cmdFindCity_Click() wkFoundInd = "No " datDonor.Recordset.MoveFirst Do While wkFoundInd = "No " And Not datDonor.Recordset.EOF If UCase(datDonor.Recordset.Fields("City").Value) = UCase(txtCity) Then wkFoundInd = "Yes" txtIdno = datDonor.Recordset.Fields("Idno").Value txtName = datDonor.Recordset.Fields("Name").Value Else datDonor.Recordset.MoveNext End If Loop If wkFoundInd = "No " Then MsgBox "City entered is not on file", vbOKOnly, "Message" datDonor.Recordset.MoveFirst End If End Sub Compares the data in the city field on the database to the data keyed into txtCity. The comparison is made using upper case versions of both sides to assure maximum chance of success. I am now going to the recordset fields and getting the values to put into the text boxes.
24
Private Sub cmdFindId_Click() wkFoundInd = "No " datDonor.Recordset.MoveFirst Do While wkFoundInd = "No " And Not datDonor.Recordset.EOF If datDonor.Recordset.Fields("Idno").Value = txtIdno Then wkFoundInd = "Yes" txtName = datDonor.Recordset.Fields("Name").Value txtCity = datDonor.Recordset.Fields("City").Value Else datDonor.Recordset.MoveNext End If Loop If wkFoundInd = "No " Then MsgBox "Id number entered is not on file", vbOKOnly, "Message" datDonor.Recordset.MoveFirst End If End Sub PrDonor5.vbp Compares the data in the Idno field on the database to the data keyed into txtIdno. I am now going to the recordset fields and getting the values to put into the text boxes.
25
DAO (Data Access Objects)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.