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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use variable instead of form name. 1

Status
Not open for further replies.

cgarts

Technical User
May 9, 2002
67
0
0
US
I want to simplify some code and eliminate some hardcoding.

I use a seach form with many other forms. The other forms call up the search form, and then receive back data from the search form.

I store the name of the original "calling" form in the tag of the search form, and then use it to send data back to the originating form.

My current code works but is a little clunky, and has to be added to whenever I add new forms that will use the search form.

The relevant snippet of code in the search form is

Select Case Me.Tag
Case Is = "FrmA"
Forms!FrmA.Tag = LstWalk.Tag
Forms!FrmA.Requery
Case Is = "FrmB"
Forms!FrmB.Tag = LstWalk.Tag
Forms!FrmB.Requery
Case Is = "FrmC"
Forms!FrmC.Tag = LstWalk.Tag
Forms!FrmC.Requery
Etc....
End Select


That works but ....can I eliminate hardcoding the name of the originating forms over and over and let some variable do the work?


What I am hoping for in pseudocode:

SendingFormNameVariable.tag = LstWalk.Tag
SendingFormNameVariable.requery



Or something like that - just a couple of lines that "understand" where to point the information.

Thanks in advance!

C
 
Try something like this:
Forms(Me.Tag).Tag = LstWalk.Tag
Forms(Me.Tag).Requery

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks!!

Sooo simple! That should clean things up.

C
 
I'd like to know a little more re "tag." Please explain this just a little more for someone unfamiliar with tags.

Thanks!

John Harkins
 
See the property dialog on form, reports and other controls, the "other" tab. At/near the bottom is the .Tag property, that Access doesn't use, but we might use for different purposes. Available at both run time and design (hit F1 when the cursor is within the .Tag property in the property dialo).

There's a little sample available for instance in the faq faq702-5010, section 3.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top