View Full Version : Open form to related record in another form


DebbieV
07-21-2003, 01:55 PM
Hi,

Can you tell me how, if it is possible when I put data in a form and then click a command button to take me to another form. I would like a record to appear that corresponds with the info in the first form. For example. I have someones name, address and phone number in a form, I click on a emergency form, I would like the record to apper so that I can just put the emergency info into that record rather than entering their name and such again.
I am finding that some how I am creating a new record in this emergency form but it doesn't appear unless I get off the record and then click back on it then click the emer form. But this won't take me to that exact record it just creates a partial record and when I try to create a new record, I get a messsage that I have duplicate data.
any help in this is most welcomed.

DebbieV

Fizzio
07-22-2003, 12:44 AM
You must be using bound controls on both forms to the same datasource and therefore getting conflicts. Use the WHERE argument in the docmd.openform statement to filter the new form to only the current record. The new record must be saved before you add to that dataset as when you input data, until you either save that record or move to a new one, the record is 'pending' (for want of a better phrase)

So therefore in the OnClick event of the command button,

Docmd.Runcommand accmdSaveRecord
Docmd.openform "formname",,,"[YourIDField] = " & me.FormsIDControl

In the second form, only bind the controls you want to change ie the emergency details.
Make the others unbound and just refer to the previous forms data ie in the controlsource of the name field

=Forms!FormName!NameField

does this help?

DebbieV
07-25-2003, 01:04 PM
Thanks Fizzio

That works fine.

DebbieV