B
Barth Wilsey
I have 2 tables
tblPatients (key field medrec)
tblQuestions (key field date and medrec)
the relationship is one to many (tblPatients one, tblQuestions many based
upon date of completion)
I am trying to capture input by using a series of forms that ask simple
questions for the patients to complete
I keep getting a message that the data could not be saved because it would
cause duplicate entries in tblQuestions
I have used the following means to try to have the forms work on the same
record (suggested in a previous message)
1) I set a parameter in the query feeding the second form that
would refer to the ID field of the record on the first form to limit the
query
to only that record.
2) I supplied a filter criteria (using the criteria in #1) in the
DoCmd.OpenForm call to filter the form when it opens.
3) I had the second form check the ID field of the record in the
first form as it opens and use the Recordset object of the second form and
do a FindFirst to go to the correct record.
Below is sample code for the third option used in one of my forms:
Public Function WorstPain()
On Error GoTo Err_WorstPain
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblQuestions", dbOpendynset)
rs.MoveFirst
Do Until rs.EOF
With rs
.FindFirst "[MedRec] = """ & Me.txtMedRec & """"
.Edit
!WorstPainPastWeek = Me.optFrame2
.Update
End With
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
Exit_WorstPain:
Exit Function
Err_WorstPain:
MsgBox Err.Description
Resume Exit_WorstPain
End Function
Can you please tell me how to .findfirst for two key fields (date and
medrec)?
Any thoughts as to why the first two methods enumerated above do not work?
thanks in advance, Barth
tblPatients (key field medrec)
tblQuestions (key field date and medrec)
the relationship is one to many (tblPatients one, tblQuestions many based
upon date of completion)
I am trying to capture input by using a series of forms that ask simple
questions for the patients to complete
I keep getting a message that the data could not be saved because it would
cause duplicate entries in tblQuestions
I have used the following means to try to have the forms work on the same
record (suggested in a previous message)
1) I set a parameter in the query feeding the second form that
would refer to the ID field of the record on the first form to limit the
query
to only that record.
2) I supplied a filter criteria (using the criteria in #1) in the
DoCmd.OpenForm call to filter the form when it opens.
3) I had the second form check the ID field of the record in the
first form as it opens and use the Recordset object of the second form and
do a FindFirst to go to the correct record.
Below is sample code for the third option used in one of my forms:
Public Function WorstPain()
On Error GoTo Err_WorstPain
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblQuestions", dbOpendynset)
rs.MoveFirst
Do Until rs.EOF
With rs
.FindFirst "[MedRec] = """ & Me.txtMedRec & """"
.Edit
!WorstPainPastWeek = Me.optFrame2
.Update
End With
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
Exit_WorstPain:
Exit Function
Err_WorstPain:
MsgBox Err.Description
Resume Exit_WorstPain
End Function
Can you please tell me how to .findfirst for two key fields (date and
medrec)?
Any thoughts as to why the first two methods enumerated above do not work?
thanks in advance, Barth