+ Reply to Thread
Results 1 to 5 of 5

Help needed with Userform / arrays

  1. #1
    Forum Contributor
    Join Date
    09-16-2004
    Posts
    100

    Help needed with Userform / arrays

    I need to do something which I think is possible, but I have no idea how to go about it.

    I have a Userform with 3 textboxes in it (Login number, name, and Staff number).

    What I want to do is set it up so that the user can type in a login number, click a button, and the other 2 boxes will complete automatically.

    I have set up 3 arrays to correspond with the textboxes.

    Now to the bit I can't figure.

    What I need to do now is, when a login number is entered, it finds the login number in the Login array, and passes the position of the login number to a variable (i.e. if the login number entered is entry 5 in the array, the number 5 would be passed to a variable). I could then use that variable to pass name(5) and Staffnumber(5) to the relevant textboxes.

    Can this be done? Sorry for the longwinded explanation.

  2. #2
    Forum Contributor
    Join Date
    09-16-2004
    Posts
    100
    Any ideas at all?

    To clarify, I want to search through an array, and report the position of the record found to a variable.

    Thanks.

  3. #3
    Forum Contributor
    Join Date
    11-16-2004
    Posts
    282

    Passing position (index) of an array to a variable

    madbloke,

    Copy the following code to the code page of your form. It will load 3 arrays with 10 items each, then veirfy the entry in TextBox1 against entries in the first array. If a match is found, it will populate TextBox2 with the corresponding value from array 2 and will populate TextBox3 with the corresponding value from array 3. If no match is found, a message dialog will alert the user. Array 1 is loaded with values "LoginID1", "LoginID2" ..."LoginID10" to test as an entry in TextBox1:

    Please Login or Register  to view this content.
    Hope this helps,
    theDude

  4. #4
    Forum Contributor
    Join Date
    09-16-2004
    Posts
    100
    Cheers for that, Dude. Unfortunately, I can't actually get this to work. I've set up the arrays to test it, but whatever I type in, it comes up with the 'Invalid Login" error message. From what little I know about coding, it looks like it SHOULD work. I can't quite figure out why it doesnt.

    Quote Originally Posted by theDude
    madbloke,

    Copy the following code to the code page of your form. It will load 3 arrays with 10 items each, then veirfy the entry in TextBox1 against entries in the first array. If a match is found, it will populate TextBox2 with the corresponding value from array 2 and will populate TextBox3 with the corresponding value from array 3. If no match is found, a message dialog will alert the user. Array 1 is loaded with values "LoginID1", "LoginID2" ..."LoginID10" to test as an entry in TextBox1:

    Please Login or Register  to view this content.
    Hope this helps,
    theDude

  5. #5
    Forum Contributor
    Join Date
    09-16-2004
    Posts
    100
    Ok, just me being dense!!

    I've figured it out now, and it works perfectly. Thanks again!

    Quote Originally Posted by madbloke
    Cheers for that, Dude. Unfortunately, I can't actually get this to work. I've set up the arrays to test it, but whatever I type in, it comes up with the 'Invalid Login" error message. From what little I know about coding, it looks like it SHOULD work. I can't quite figure out why it doesnt.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1