Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2013
    Posts
    16

    Display value in text box related to value in another textbox on clicking navigation

    I have a table by name customer
    fields :
    Fields name Data Type
    customer id auto number
    fname text
    lname text
    referred number

    each customer is referred by another customer

    when I navigate by next or previous button I should get the name of referrer displayed in referrer's name text box related to referred customer id
    I tried writing n number of events however I want to know how can it be focusing to the referred ID combobox. i have attached my sample database please help me to resolve this issue


    Thanks in Advance
    Attached Files Attached Files

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    First off, go into Table Design View and delete the 0 from the Default Value for the Field named referred. Best to do this by hi-lighting it and hitting Delete.

    If I understand your question correctly, use this code in the Form’s Code Module

    Code:
    Private Sub Form_Current()
     
     Dim LN As String
     Dim FN As String
     
     If Not Me.NewRecord Then
    
      LN = DLookup("lname", "customer", "customer_ID = " & Me.Combo7)
      FN = DLookup("fname", "customer", "customer_ID = " & Me.Combo7)
      Me.Text9 = LN & "  " & FN
     
     Else
      
      Me.Text9 = Null
     
     End If
    
    End Sub

    If you want the referrer's name to appear immediately after selecting the ID from the Combobox, use this:

    Code:
    Private Sub Combo7_AfterUpdate()
     
     Dim LN As String
     Dim FN As String
     
      LN = DLookup("lname", "customer", "customer_ID = " & Me.Combo7)
      FN = DLookup("fname", "customer", "customer_ID = " & Me.Combo7)
      Me.Text9 = LN & "  " & FN
     
    End Sub

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,524
    Can't look at the sample right now, but does this help?

    http://www.baldyweb.com/Autofill.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Join Date
    Jul 2013
    Posts
    16

    Smile Thanks Missinglinq zillions times

    Thanks Missinglinq zillions times
    your first code resolved my issue
    past 2 weeks i was scratching my head
    hope to catch u till i finish my project
    Thanks Again..

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Welcome to the forum!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,524
    I would have avoided the 2 extra trips to the data, but that's me.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I would have, too, Paul! But when working with newbies, I tend to work with what they already have! And most of them aren't working with apps that are big enough to suffer from an extra trip to the data, given the speed of today's PCs!

    Now, when I was a young lad...and we had 20 mb hard drives...

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 8
    Last Post: 09-08-2013, 12:34 AM
  2. Link two forms to display related data
    By KrisDdb in forum Forms
    Replies: 3
    Last Post: 09-19-2011, 02:41 PM
  3. Replies: 3
    Last Post: 08-18-2011, 07:31 AM
  4. Replies: 2
    Last Post: 11-16-2010, 10:55 AM
  5. Replies: 5
    Last Post: 02-10-2010, 12:27 AM

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