R
Ryan W
I have tried everything that I can think of, without any real results.
I have a form w/subform on it in Access 2000. My PK is MedicalRecord, with
two text boxes Lname and Fname. On the subform my PK is VisitID and FK is
MedicalRecord. These forms are linked by MedicalRecord. Also on the subform I
have VisitDate and Physician.
What I am trying to accomplish is to have a combobox lookup on the main
form that will look up the MedicalRecord and if the combobox does not find
the record, it will ask the user if they want to add the record. When the
user selects yes, a new form will appear which will allow the user to enter
the patients first name and last name and the MedicalRecord will come across
from the combobox.
I have my combobox looking up the values without any problem. I also have it
so that when it is NotInList that anothe form appears with the MedicalRecord
in the designated space, and the user has two text boxes so that they can
enter the first/last name. But when I select ok on my pop-up form, it does
not update the main form (add a new record). It is adding the new
MedicalRecord to the forms current record.
Here is what I have done:
I have three text boxes on my main form w/one combo box. Textboxes:
txtMedicalRecord, txtLname, txtFname. I used the wizard to create the look up
combo box, cboMedicalRecordSearch. When I used the wizard, it gave me code
for the look up which is in the afterupdate field:
Private Sub cboMedicalRecordSearch_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CMSLName] = '" & Me![MedicalRecord] & "'"
Me.Bookmark = rs.Bookmark
End Sub
Here is what I have for NotInList
Private sub cboMedicalRecordSearch_NotInLIst( _
Newdata as string, Response as integer)
Dim strmsg as string
Dim rst as DAO.recordset
Dim db as DAO.database
strmsg = " ' " & Newdata & " 'is not in the list."
strmsg = strmsg & "Would you like to add it?"
If vbno = msgbox(strmsg, vbyesno +vbquestion, _
"New Patient") then
Response = acdataerrdisplay
else
set db = currentdb()
set rst = db.openrecordset ("tbldemographics")
rst.addnew
rst("MedicalRecord") = Newdata
rst.update
response = acdataerradded
rst.close
end if
end sub
Where and what would I add in order to add a new record when the user select
"yes" to add that new record? Hope that this makes sense. Any help would be
wonderful! I have been working on this for a week now.
I have a form w/subform on it in Access 2000. My PK is MedicalRecord, with
two text boxes Lname and Fname. On the subform my PK is VisitID and FK is
MedicalRecord. These forms are linked by MedicalRecord. Also on the subform I
have VisitDate and Physician.
What I am trying to accomplish is to have a combobox lookup on the main
form that will look up the MedicalRecord and if the combobox does not find
the record, it will ask the user if they want to add the record. When the
user selects yes, a new form will appear which will allow the user to enter
the patients first name and last name and the MedicalRecord will come across
from the combobox.
I have my combobox looking up the values without any problem. I also have it
so that when it is NotInList that anothe form appears with the MedicalRecord
in the designated space, and the user has two text boxes so that they can
enter the first/last name. But when I select ok on my pop-up form, it does
not update the main form (add a new record). It is adding the new
MedicalRecord to the forms current record.
Here is what I have done:
I have three text boxes on my main form w/one combo box. Textboxes:
txtMedicalRecord, txtLname, txtFname. I used the wizard to create the look up
combo box, cboMedicalRecordSearch. When I used the wizard, it gave me code
for the look up which is in the afterupdate field:
Private Sub cboMedicalRecordSearch_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CMSLName] = '" & Me![MedicalRecord] & "'"
Me.Bookmark = rs.Bookmark
End Sub
Here is what I have for NotInList
Private sub cboMedicalRecordSearch_NotInLIst( _
Newdata as string, Response as integer)
Dim strmsg as string
Dim rst as DAO.recordset
Dim db as DAO.database
strmsg = " ' " & Newdata & " 'is not in the list."
strmsg = strmsg & "Would you like to add it?"
If vbno = msgbox(strmsg, vbyesno +vbquestion, _
"New Patient") then
Response = acdataerrdisplay
else
set db = currentdb()
set rst = db.openrecordset ("tbldemographics")
rst.addnew
rst("MedicalRecord") = Newdata
rst.update
response = acdataerradded
rst.close
end if
end sub
Where and what would I add in order to add a new record when the user select
"yes" to add that new record? Hope that this makes sense. Any help would be
wonderful! I have been working on this for a week now.