• Populating fields in forms (Word 97 SP2)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Populating fields in forms (Word 97 SP2)

    Author
    Topic
    #381556

    Good Evening!

    I am currently updating some Word forms and want to be able to populate some fields from previous entries. I’m hoping to be able to link login details (win2K) to a text file so that the form will recognise the person that has logged in – and will prefill some of the information on the form. I also would like to prompt a user that has never logged onto that specific machine for some information that can be used in the form.

    Hopefully I’ve come to the right place for some well needed direction!

    Thanks for any help

    Alba

    Viewing 1 reply thread
    Author
    Replies
    • #643580

      Would you consider using the Registry to store the information? I have several classes that
      push and pull from the registry — which I prefer to .ini files. If you search this forum, you’ll find
      biases both ways. The new thing is storing all such settings in XML files. But wait for the .net
      version of VBA (VSTO) before jumping into that one.

      • #643755

        Kevin,

        Using the registry might depend on how the registry is set up.

        On our site, the registry is machine specific, not user specific. So we use ini files on the users’ network personal folders.

        We have another problem. Many bosses do not fill in their own forms- thay have their PA do it for them. The PA will also have to fill in forms for themselves; the may also be working for mor ethan one person. We give them the ability to switch from one user to the other, carrying all personal information with them.

        • #644011

          >>On our site, the registry is machine specific, not user specific

          Geoff,

          I don’t quite understand that statement. The reg hives HKEY_Current_User and
          HKEY_Local_Machine exist on all Windows PCs, don’t they?

          I solved the user1 doing work for/as user2 by building the hooks into the app
          to allow “impersonation” via the form prompts.

          • #644062

            Sounds as though I may have bitten off more than I can chew….I’ve had a chance to think about it a bit more, and had realised that our bosses can’t type either and the secretaries can be working for up to 6 people at a time.

            So what I thinking is to compare the username of the person logged on, with an .ini file. The first time a person logs on and opens one of the forms they will be prompted to fill out some basic information – which is then written to the .ini file and stored for the future. This info in turn can then be used to populate fields in a number of templates.

            Sounds OK so far?

            But I’m curious as to how you can prompt the user to switch to become another user or to “impersonate” another user? I was thinking of a locally stored .ini file, so how do you get round the problem of updating the file on everyone’s machine when someone new starts?

            Sorry if I appear dim, but I don’t want to go down the wrong route…..

            • #644080

              Hey, none of that dim business. That’s a VB reserved word, so lay off.

              All your questions have been just fine.

              …and here’s how it’s done:

              See that drop down (combo btn) for Name: behind that button
              is the entire employee list. Any user can change
              that to whomever they like. If you need any restrictions, that’s easy
              enough to code up. All the basic user profile info is stored in a
              centralized db and pulled in from there to the form. The user’s choices
              are then stuffed into the HKEY_Current_User hive for the app.

              The beauty of the registry is it holds these values
              in place of global variables and since the registry is cached, access
              is very fast. I made it easy for the user: as soon as they pick a name
              from the list, all the other fields populate.

              Wrap all this up in a couple class mods and you can
              reference any profile setting like this:

              txtName.Text = oPro.Fullname

    • #643765

      What kind of logon details? The last person logged on and that sort of thing?

    Viewing 1 reply thread
    Reply To: Populating fields in forms (Word 97 SP2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: