View Full Version : Passing information between screens


Godfrey2
04-11-2001, 07:38 AM
Hi there. I am a non Access person who has been lumbered with a halffinished database :-(. I need to find out how to pass information between screens. I have a command button on a screen that allows accessing a form with a search facility for a persons name. I can select the name that I want and then click on a select button. Currently, the information is passed back to a specified field on a certain form. I used the itemselected and columns functions. It works fine.

However, I want to reuse this code in other places so I need a method to say, whatever the page that I orginated the search, pass the information back to that page and to a specified fields. There are numerous places in the database that requires name lookups.

The database is for a charity so if anyone can offer me some advice, I would be extremely grateful.

Chris RR
04-11-2001, 10:24 AM
This isn't a full solution, but here's something that I've found helpful. It does involve VBA code, though.

Rather than passing info from FormA field to FormB field, I set up global variables for the stuff I commonly need to refer to, by creating a module named something like "modGlobalVariables" and putting in code like this:

Public strWhichForm As String
Public strWhichRec As String


Then, in each form I fill in the fields like this, before I switch to any other form:
strWhichForm = Me.Name 'my current form name, not a field on my form
strWhichRec = Me.txtRecID 'a field on my form

I can use these fields in whatever form I open, to do whatever needs to be set up the form OR even to go back to the form I came from (with a Docmd.OpenForm strWhichForm). If you only need a field in one particular circumstance, I would not do this, but it is helpful for common choices.

Godfrey2
04-12-2001, 07:11 AM
A big thanks to Chris. This put me on the right track! The Play center in Nottingham will be well chuffed with this. Its a centre for chilren with disabilities and our compnay is doing this for them.