Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    4

    Unanswered: a selection in one field will populate another field

    I am trying to cross-reference a command code with a geographic location. I want the user to select the command code and the geographic location will populate with the correct location for that command code. The problem is that there are many command codes for each geographic location.

    for example:

    Geographic Location: DBB
    Command Codes: 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110

    Geographic Location: DBBX
    Command Codes: 1,5,6,7,9,10,13,14,17

    etc, etc.....

    I want my user to select, on the form, the Command Code for the specific entry they are making, and I will have access supply the appropriate Geographic Location.

    Any HELP!
    Thank You.

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,420
    Provided Answers: 7
    as i have used text make shoure you set the row source type is 'Value List'

    if you want to use QUERY OR sql

    row source type is 'Table/Query'

    AND CHANGE LOC1 LOC2 TO THE RIGHT QUERY NAME OR SQL



    Code:
    Option Compare Database
    Dim loc1 As String
    Dim loc2 As String
    
    Private Sub Combo2_Change()
    If Me.Combo2.Text = "DBB" Then
    Me.Combo0.RowSource = loc1
    Else
    Me.Combo0.RowSource = loc2
    End If
    End Sub
    
    
    Private Sub Form_Open(Cancel As Integer)
    loc1 = "100;101;102;103;104;105;106;107;108;109;110"
    loc2 = "1;5;6;7;9;10;13;14;17"
    Me.Combo2.RowSource = "DBB;DBBX"
    End Sub
    See clear as mud
    stephan McKillen

  3. #3
    Join Date
    Jan 2004
    Posts
    4

    one more question

    I currently list all Geographic locations in one table

    tblBorough
    DBB
    DBM
    DBQ
    DBBX

    and I list all command codes in another table

    tblCmd
    100
    101
    102
    40
    41
    30
    9
    5

    Will have to re-do my tables so that your code will work. I only have one table for all command codes and one table for all geographic locations.

    I still want my user to have a drop-down menu, in my form, of all command codes to choose from. This drop-down is limited to the list.

    Thank you

  4. #4
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,420
    Provided Answers: 7

    NO

    change the
    row source type is 'Table/Query'


    in Me.Combo2.RowSource = "SELECT table1.tblBorough FROM table1 GROUP BY table1.tblBorough;"

    or hard code it in


    change

    Code:
    Private Sub Combo2_Change()
    
    Dim Sql as String
    Dim LikeThis  as String
    
    LikeThis = Me.Combo2.Text
    sql = ""
    sql=sql & " SELECT other.tblCmd"
    sql=sql & " FROM other"
    sql=sql & " WHERE (((other.tblBorough) Like '" & LikeThis &'))"
    sql=sql & " GROUP BY other.tblCmd;"
    
    Me.Combo0.RowSource = sql
    Me.Combo0.Requery
    ..
    ..
    ..
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

Posting Permissions

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