Results 1 to 6 of 6
  1. #1
    shelzmike is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2010
    Posts
    22

    Dynamically Updating (Display) Unbound Label based on Input from Another Textbox

    I hope this will make some sense.



    I have a bound textbox called techNum in which the user can enter any 4 digit number that corresponds to one of our technicians numbers. I also have an unbound label called FSM, which will hold the name of their manager, but this label will need to be read only yet change based upon what the user enters in the techNum field.

    I have two lookup tables that I am referencing here.

    techTbl
    [techNum],[techName],[fsm_Id],[longTechNum]

    -AND-
    fsmTbl
    [fsm_id],[fsmName],[longFSMID]

    So, on the form, when a user enters say, 2900, for the tech number I want that number to be looked up on the techTbl, find the fsm_Id, then return the fsmName associated with that fsm_Id on the fsmTbl. I want the returned fsmName to be posted in the aforementioned unbound label.

    How can I do this? For some reason when I list it out like that it sounds more complicated that I think that it should.

    Mike

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Label cannot be bound to data. You can programmatically set their Caption property.

    Instead, you might just modify the form's RecordSource to include joins with techTbl and fsmTbl. Be careful to get the JoinType correct. Then you can display the name info in locked textboxes.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    shelzmike is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2010
    Posts
    22
    Thanks for the reply. Actually, it was much easier than that. I changed the control to a textbox and then used a DLookup function in the AfterUpdate event of the techNum textbox on the form.

    This worked beautifully. However, now I have to figure out how to be sure that the TechName textbox is cleared of any data on each new subsequent record navigation or creation.

    What I mean is that this process works as it should on an individual record; however, it retains the changed data when I move about the record set, making the others incorrect.

    Any tips on that?

    Mike

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Use the join in RecordSource or repeat the VBA code in the form OnCurrent event.

    So which is easier - the join or figuring out everywhere need code to trigger the refresh of the textbox?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    shelzmike is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2010
    Posts
    22
    This may show my novice status in all its glory, but I do not see the OnCurrent event in the properties for events. Is this something that needs to be added in VBA explicitly? Also, I am guessing by your wording in the last response that using the join is easier, though I am not fully sure how to do that either! Thanks for the push in the right direction though> Thanks!

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    OnCurrent is an event of the form, and it is the first one in the list. You must have the form selected, not a control. Click the form in the upper left corner or from the Properties dialog dropdown list click the Form item.

    RecordSource for a form can be a table or a query. Query can include joins to other tables/queries. You can build the query and save it as an object and reference the query in the form RecordSource or build the query right in the RecordSource property. In the latter there will not be an Access query object saved, just an SQL statement in the RecordSource. Click the ellipses (...) to open the designer and build.

    Those two events might be adequate if you want to go the VBA route. However, the join does not require any VBA.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Display PASS or FAIL using Unbound textbox
    By Shambler2 in forum Reports
    Replies: 7
    Last Post: 06-02-2011, 11:19 AM
  2. Updating record based on textbox entry
    By timmy in forum Programming
    Replies: 16
    Last Post: 04-06-2011, 12:05 AM
  3. Replies: 1
    Last Post: 08-13-2010, 01:06 AM
  4. Replies: 2
    Last Post: 06-17-2010, 04:15 PM
  5. Replies: 1
    Last Post: 06-01-2009, 04:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums