Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Access: How do forms communicate values to each other?

Tags:

ms-access

I have a form (FORM-A) that requires the user to select a vehicle. The user should click on a button on FORM-A that say's select vehicle. A selection form (FORM-B) should open where the user can select a vehicle. The selected value should be communicated back to FORM-A.

How would you accomplish this in MS Access 2010?

FORM-B is a continuous form that contains a picture of the vehicle and some other information.

like image 260
cmaduro Avatar asked Dec 29 '10 15:12

cmaduro


1 Answers

From what I understand from your question, you want formB to open a kind of pop-up. When the pop-up is closed, its result is put somehere in the calling form.
Solution proposal:
a) open FormB using syntax docmd.openform "formB", windowmode:=acDialog.
This will prevent execution of the next lines until formB is closed or hidden.
b) in the OK button of FormB, just hide the form, do not close it.
c) when code resumes in formA, you can now

  1. check if formB is still open. If not, it's been cancelled
  2. read the value in hidden formB (still open), then close formB

Otherwise, you could also have formB to update a control in formA before closing. But I don't like that approach because then formB is not reusable, and it creates an unnecessary dependency between formB and formA.

like image 80
iDevlop Avatar answered Nov 05 '22 20:11

iDevlop