using a database access97 please use speaker notes for additional information!
DESCRIPTION
VB formTRANSCRIPT
Using a DatabaseAccess97
Please use speaker notes for additional information!
donor.mdb
VB form
VB formConnect contains Access so it does not have to be reset, for another database it would.
VB form
Text boxes
Text boxes
Output
Change
Before change
After change
PrDonor1.vbp
The click events are programmed to move through the Recordset called datDonor as using methods as coded above.
PrDonor1.vbp
Visible set to False for datDonor so the data control does not appear on the form.
PrDonor2.vbp
Private Sub cmdChangeCity_Click() datDonor.Recordset.Edit datDonor.Recordset.Fields("City").Value = txtChangeCity datDonor.Recordset.UpdateEnd Sub
Before
After
PrDonor3.vbp
PrDonor3.vbp
Private Sub cmdAdd_Click() datDonor.Recordset.AddNewEnd 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.
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.
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.DeleteEnd Sub
PrDonor3.vbp
PrDonor4.vbp
Find Id results in the input box where the user can enter the id number of the record they want to locate.
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.
PrDonor4.vbp
PrDonor5.vbp
PrDonor5.vbp
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.
PrDonor5.vbp
Dim wkFoundInd As String
Private Sub cmdExit_Click() EndEnd Sub
Private Sub cmdFindCity_Click()wkFoundInd = "No "datDonor.Recordset.MoveFirstDo 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 IfLoopIf wkFoundInd = "No " Then MsgBox "City entered is not on file", vbOKOnly, "Message" datDonor.Recordset.MoveFirstEnd IfEnd 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.
Private Sub cmdFindId_Click()wkFoundInd = "No "datDonor.Recordset.MoveFirstDo 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 IfLoopIf wkFoundInd = "No " Then MsgBox "Id number entered is not on file", vbOKOnly, "Message" datDonor.Recordset.MoveFirstEnd IfEnd 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.
DAO (Data Access Objects)