Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form & subForm; how to add new item to subform

Status
Not open for further replies.

tyemm

Technical User
Feb 28, 2005
66
US
I am getting an error: you must save the record before going to a SetFocus or GoToForm action.

The cause is I have a form and a subform, one is addPatient and the other is addIncident.

I'd like to trigger an action when a user attempts to add a duplicate patient: no duplicate patient IDs are allowed, of course, but multiple Incident IDs for a single patient are allowed.

I have currently an event on txtPatientID on the frmPatientAdd form such that the user is informed that the PatientID already exists, and then the focus is redirected to the sfrmAddIncident subform, ideally with the proposed PatientID carried over into the subform, i.e. to [sfrmIncidentAdd]![cboPatientID].value.

But I'm getting an error! What I am doing on duplicates is to "undo" or cancel the PatientID add action before it results in an error, but then I'd like to carry that PatientID choice to the subform. It must be possible, no?

T.Y.
 
I wonder if you have set a unique index for PatientID? Also is PatientID the Linking field (Child and Master) for your subform?

I think you must first find the correct record for the proposed PatientID, then set focus to the subform. I would imagine a series of events:
Duplicate ID entered
Update cancelled, probably with the On Before Update event
Correct record found, probably using a recordsetclone and bookmark
Focus set to subform.

A message box might be useful, too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top