Transferring Data from one form to another- Microsoft Access

By toddmehl ·
After spending hours looking online at various posts, I am at a loss.

I am trying work on a couple forms that share the same primary key ("Incident#"). I am typing in the data into the first form called "RunReport". I have a command button further down the page labelled "EMSCall". When I push the fancy button, it does fancy things (not that fancy, but anyway) with colors of the button, and then it opens another form "EMSCall". "RunReport" is linked to table "RequiredInfoAllCalls" and "EMSCall" is linked to table "MedicalInjury".

When that second form opens, I want to be able to see some of that data from the first page, mainly the value of the Primary Key "Incident#". Instead I get the message: "You cannot add or change a record because a related record is required in the table "RequiredInfoAllCalls". I can type in the exact same values in each field and it still gives me the dreaded message.

I am thinking it has to do with the relationships of the tables. I set up a one-to-one relationship for the tables, between the primary keys "Incident#". I also have them set up with referential integrity and tried varying the possible join types (3 of them in Access).

Does anyone have any ideas on how to fix this and eliminate the dreaded message? Any, and all, assistance will be appreciated! Thanks!


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

Transferring Data from one form to another- Microsoft Access

by mail In reply to Transferring Data from on ...

It appears to me that when you click the EMSCall button to open another form you are doing this to add a related value in Table MedicalInjury via the bound EMSCall form. If that is so, then clearly the recorded created on the form RunReport has NOT been saved to the table RequiredInfoAllCalls, so adding that value in the MedicalInjury has no related value. You MUST first save the data to the table RequiredInfoAllCalls before opening the bound EMSCall form. Ti do this, on the Click Event of the EMSCAll button type the following BEFORE opening the EMSCall form with the Docmd.Openform command

Dim bSave as boolean (define this in the General section of the form)

If Me.Dirty then Me.dirty = False
if bSaved then
Docmd.Openform ...... 'execute Open if the form has been saved
End if

This line (Me.Dirty..) will force data in memory to be flushed from the buffer to the hard disk. If variable bSave is equal to True then openform
Now in the Form_BeforeUpdate Event (triggered from the Me.Dirty line), have some code that checks that compulsory fields have data in it or else for each blank field have code like

If Trim(Nz(Me.Description)) = "" then
MsgBox "You cannot leave field 'Decription' blank"
Cancel = True
End If
The LAST line (after all MsgBox field validations are done) MUST BE

bsave = True

This will cancel the SAVE. But if no problems occurred, then bSave value will be changed to True and the next line in the EMSCall button Click will open the form

Collapse -

Thank you!

by toddmehl In reply to Transferring Data from on ...

Thanks, I will try that out once I get near the program again. I have tried for a couple days to get that feature to work. Also, your name is showing up as mail@... I will let you know how it works.


Collapse -

It works!

by toddmehl In reply to Thank you!

Thank you very much! I used the first half (the me.dirty part) and it got everything to work great! Thank you for your time!


Collapse -

Transferring data from one form to another

by mail In reply to It works!
Collapse -

Need help with MS Access Forms

by 02tones02 In reply to Transferring data from on ...


I am completely new to MS Access however, I've been learning my way through. I have created several tables that are linked via primary key of "patient ID." Unfortunately, whenever I try to place all the fields from each of these tables onto a single form or even a multiple tab forms, the "wizard" says that "Out of range." I think that means I cannot add that many fields using the wizard.

So, I've created 3 forms; each containing a multitab form with approx. 4 tabs each. Is there a way to link the forms so that when I type in a unique patient ID in the first form, that patient ID is carried throughout the other 2 forms thereby create one large record for that particular patient?

Any comments or advice would be greatly appreciated.



Related Discussions

Related Forums