Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    May 2001
    Location
    indiana
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Referencing Controls (97)

    hi all
    i have several forms for entering certain information, including employee ID and manager ID, for example. i have a text box to enter each of these, and if the value matches an existing employee, then the employees name and department are displayed. if the value in the text box doesn't match an existing employee, i flip to a new form to enter employee information in more detail. what i would like to to is this... i want to be able to use the detailed information form for either the employee or the manager, on several different forms. is there a way to set a variable in the detailed information form to check which control on which form the request came from, so the appropriate information can be returned to the right place when i am finished entering the infromation? i hope this isnt too hard to understand

    thanks in advance

  2. #2
    2 Star Lounger
    Join Date
    May 2001
    Location
    indiana
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Referencing Controls (97)

    hmm.. thank you for replying so quickly
    what i'm trying to do (which i didn't really explain very well) is set a variable in the second form (the detailed information form) to whatever control i want to update. for example: forms!frmTestForm.lblEmployeeName
    and then, when i am finished entering all information, it would update the original control with the new employee name. it didnt look like the openargs property would do that, maybe i'm wrong.

    p.s. i know i can do this with if/then statements, which i have done in the past. however in this project there are many instances of this i would like to use, and i would like to just set a variable for the source of the request to just return back to there with the new information, without covering all instances my project references a certain form.

    thanks again

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Referencing Controls (97)

    I think what you're looking for is the OpenArgs string that you can pass in the DoCmd.OpenForm statement. Pass the name of the control itself to the other form, use the OpenArgs property of the second form to retrieve the string, and you'll be able to set the focus back to that control by fully referencing it from the other form. Actually, the method I prefer to use is to open the second form using automation and controlling everything from within the calling form. Look up WithEvents in on-line help for a quick look at that approach. There are also examples of same in the Solutions.mdb that should be on your Office CD. And there is also a sample forms database for 97 that you can download from <A target="_blank" HREF=http://support.microsoft.com/support/kb/articles/q175/0/66.asp>http://support.microsoft.com/support/kb/ar...s/q175/0/66.asp</A> that illustrates all sorts of cute tricks with forms.

    At least, I'm assuming that "i flip to a new form to enter employee information" means you're opening a new form. If you're talking about something like a subform on a tab control, that's different.
    Charlotte

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Referencing Controls (97)

    In that case, look at the additional info I added to my message and see if that helps you. OpenArgs will allow you to pass a string containing whatever you want to the other form. You could pass it a delimited string containing the form name plus a semicolon plus the control name. Then on the second form, you could use the OpenArgs property to grab the string, parse it out, and set an object reference to the form's control.

    If you're using DoCmd.OpenForm, there aren't too many options that are clean. You could create a public property on the second form and set that from code, but it isn't really good programming practice to do it that way.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •