Recordset Problems??

VooDoo

New member
Local time
Today, 15:03
Joined
May 11, 2005
Messages
7
Hi all,

I am attaching current db below its not the best in the world but it suits me. lol anyway basically my problem is in the form frmAssignPatientMedication i basically want the user to select from the two combo boxes (a patient then a medicine) then click Assign and i want the database to add this info to the table tblPatientMedicine i cant seem to get my head around how the hell to do it! So any help will be greatly appreciated! Any other areas u think i could better in my db just say u'll probably be right! Thanks in advance:)
 

Attachments

Code:
Private Sub cmdAssign_Click()
  Dim SQL As String
    
  SQL = "Insert Into [tblPatientMedicine]" & _
        "([PatientID],[PatientName],[MedicineID],[Medicinename]) Values ('" & _
        Me.frmAssignMedication1a.Form!cboAssignPatient.Column(0) & "','" & _
        Me.frmAssignMedication1a.Form!cboAssignPatient.Column(1) & "','" & _
        Me.frmAssignMedication2a.Form!cboAssignMedicine.Column(0) & "','" & _
        Me.frmAssignMedication2a.Form!cboAssignMedicine.Column(1) & "')"

  CurrentDb.Execute SQL

End Sub

Note
Since the primary key of the table consists of the fields PatientID and MedicineID, the code will throw an error if you try to insert duplicate "PatientID + MedicineID" into the table.
.
 
Thanks Jon i will give this code a go in a bit, and to solve the error message you mentioned i will just place an on error line , as i think this will be enough to satisfy the user cheers and ill update this to let you know how its going
Thanks again:)

-EDIT-
Thanks code works great, i see now what you meant by the error but i will sort that out in due course.
Thanks Again
 
Last edited:

Users who are viewing this thread

Back
Top Bottom