dcsimg
Results 1 to 4 of 4

Thread: match 2 table field then display on textbox1,textbox2,textbox3...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    105

    Question match 2 table field then display on textbox1,textbox2,textbox3...

    Hi, Good day to all.

    can any one help on this ?

    i'm using microsoft access 2000, i have 2 database and 2 tables.

    table 1 (name : users)
    field : usedID,user,salesman,date1

    table 2 (name : target)
    field : name1,location1,target1,month1,year1


    I managed to display table 1 'user' data field on combo1, but how to match the 2 different fields and display the all data field from table 2 on text1,text2,text3,text4.

    below code only can display one data record..
    how to display all data from table 2, when 2 data field 'user' and 'name1' is match (highlighted RED) ?


    Code:
    Private Sub combo1.Click()
    
    if combo1.text = rs.fields("name1") then
    Text1.text = rs.Fields("target1")
    Text2.text = rs.Fields("location1")
    Text3.text = rs.Fields("month1")
    Text4.text = rs.Fields("year1")
    Else
    Text1.text = ""
    Text2.text = ""
    Text3.text = ""
    Text4.text = ""
    End If
    
    End Sub

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,409

    Re: match 2 table field then display on textbox1,textbox2,textbox3...

    Please don't post the same question multiple times. If you post in the wrong forum then use the Report Post icon under your post to ask the mods to move the existing thread to the correct forum. Now they have to delete your other thread, if they even learn that it exists.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    105

    Re: match 2 table field then display on textbox1,textbox2,textbox3...

    sorry, noted

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Java (JSP) Hell!
    Posts
    5,278

    Re: match 2 table field then display on textbox1,textbox2,textbox3...

    (Probably misunderstanding how you have it...)
    Check the properties on the combo box. there is one for column count. Change to the number of columns to use.
    Also there is a columnwidths property, change this to something like 0; 1; 1; 1
    Change the 1's to appropriate widths. 0 is to hide the first column (usually an id column that the user doesnt need to know)

    As to the code, then on the on click or on change event, put
    Code:
    Text1 = combo1.column(2)
    Text1 = combo1.column(3)
    The column to get the selected line from (assuming this is what you are asking).

    Whats the sql you are using to open for the combo?


    or, is the combo just the users.
    In which case for the second tables data, use a listbox.
    Add a query and add the combos values as the filter/parameter

    Is it bound or unbound?
    How are you filling / getting the data?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width