Hi everyone..,
I'm trying to create a simple Patient Information System and I have no idea on how to Add a new patient record in the database.
I know how to add a record using RS.AddNew and RS.Update like:
But what I actually want to do is Insert this new record in a specific page number and book number. Because here, I have tablesCode:RS.AddNew RS.Fields("PatientNo").value = txtPatientNo.text RS.Fields("FirstName").value = txtFName.text RS.Fields("LastName").value = txtLName.text 'And so on.. RS.Update
PAGE
PK - PageNo
BOOK
PK - BookNo
PATIENT
PK - PatientNo
- FirstName
- LastName
- MiddleName
- Address
- Age
'Junction Table for the Ternary Relationship
BOOKPAGEPATIENT
PK - BookNo
PK - PageNo
PK - PatientNo
The program goes like this, I open a Book Number, after opening a book number, I can open a Page from this Book that is currently opened. Once that a Page number is opened, I now have some operations like Add, Delete, Save, Edit and Cancel. But I'm actually done with some of the few buttons here.
My problem only is how to add a new Patient record in the currently opened Book and Page No.
Here is my code on the database connection which connects to ms access database:
Once that I click on the add button,Code:Global DBS As New ADODB.Connection Global patientListRS As New ADODB.Recordset 'Database Connection DBS.CursorLocation = adUseClient DBS.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & App.Path & "\CLINIC 97.mdb;MODE=ReadWrite" set patientlistrs.activeconnection = DBS patientlistrs.locktype = adlockoptimistic patientlistrs.source = "PATIENT" patientlistrs.open , DBS, , , adcmdTable
The textboxes are cleared for entry of new records and which will enable the textboxes and the Save and Cancel buttons and disable all the other buttons.
I don't know what code to use when on the save button. Please help me..


,
Reply With Quote
