Results 1 to 13 of 13
  1. #1
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Red face Unanswered: Combo Box Help in MS Access

    I'm creating this database application to keep track of clinical study documentation. I have 3 table name Study,Site and StudySIteImp.

    In table Study "StudyNo" is the PK
    In table Site "SiteNo" is the PK
    In table StudySiteImp i have linked "StudyNo" and "SiteNo" as FK

    Basically, table StudySiteImp will only have the StudyNO and SiteNo data that correspondes to each other.

    I have created the form with 2 unbound combo box. This is what i am trying to get from combo box. For example: If someone chooses a StudyNO from the 1st combo box then 2nd combo box should only list the Site for that selected StudyNO in combo box 1

    Anybody know how to do this ?

    Thanks in Advance.
    Attached Files Attached Files
    Skharva

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    First I must see your Data Base, and later I tell you what is the problem.
    Saludos
    Norberto

  3. #3
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Sorry I cant read your base is not in Access 97.
    Saludos
    Norberto

  4. #4
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    I think that the problem is in Combo 2, you must do de requery of that
    control after out of Combo 1 and when you in ( enter event ) Combo 2.
    Saludos
    Norberto

  5. #5
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by Norberto
    I think that the problem is in Combo 2, you must do de requery of that
    control after out of Combo 1 and when you in ( enter event ) Combo 2.

    If you can give me an example that would be really helpful.

    Thanks in advance
    Skharva

  6. #6
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    I send example of code
    -------------------------------------------------------- Combo 1
    Private Sub Rubro_Exit(Cancel As Integer)
    Dim Valor As Variant
    Valor = Me!Rubro
    If IsNull(Valor) Or Valor = 0 Then
    MsgBox "Debe Seleccionar Rubro", vbCritical
    Cancel = True
    Me!SIGNO.SetFocus
    Exit Sub
    End If

    Me!SubRubro.Enabled = True
    Me!SubRubro.Locked = False
    Me!SubRubro.SetFocus

    End Sub
    ----------------------------------------------------------- Combo 2
    Private Sub SubRubro_Enter()

    Forms![MovimientoCaja]![Subformulario Movimientos de Caja Pantalla]![SubRubro].RowSourceType = "Tabla/consulta"
    Forms![MovimientoCaja]![Subformulario Movimientos de Caja Pantalla]![SubRubro].RowSource = "SELECT DISTINCTROW [Consulta Gastos SubRubros].[DENSRG], [Consulta Gastos SubRubros].[CODSRG] FROM [Consulta Gastos SubRubros];"
    DoCmd.Requery "SubRubro"

    End Sub
    ------------------------------------------------------------------------------------

    Is not the same but cant help you.
    Saludos
    Norberto

  7. #7
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Here is the databaes in Access97.


    Originally posted by Norberto
    I send example of code
    -------------------------------------------------------- Combo 1
    Private Sub Rubro_Exit(Cancel As Integer)
    Dim Valor As Variant
    Valor = Me!Rubro
    If IsNull(Valor) Or Valor = 0 Then
    MsgBox "Debe Seleccionar Rubro", vbCritical
    Cancel = True
    Me!SIGNO.SetFocus
    Exit Sub
    End If

    Me!SubRubro.Enabled = True
    Me!SubRubro.Locked = False
    Me!SubRubro.SetFocus

    End Sub
    ----------------------------------------------------------- Combo 2
    Private Sub SubRubro_Enter()

    Forms![MovimientoCaja]![Subformulario Movimientos de Caja Pantalla]![SubRubro].RowSourceType = "Tabla/consulta"
    Forms![MovimientoCaja]![Subformulario Movimientos de Caja Pantalla]![SubRubro].RowSource = "SELECT DISTINCTROW [Consulta Gastos SubRubros].[DENSRG], [Consulta Gastos SubRubros].[CODSRG] FROM [Consulta Gastos SubRubros];"
    DoCmd.Requery "SubRubro"

    End Sub
    ------------------------------------------------------------------------------------

    Is not the same but cant help you.
    Attached Files Attached Files
    Skharva

  8. #8
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    I send your Base with update
    Attached Files Attached Files
    Saludos
    Norberto

  9. #9
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Thumbs up

    Great this helps. But what if i have more then one Site for one study. Between Study and Site there is M:M relationship

    Originally posted by Norberto
    I send your Base with update
    Skharva

  10. #10
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    This is what i am trying to get. I have wrote SQL for combobox2 which has all SiteNo

    SELECT DISTINCT tblStudySiteImp.SiteNo
    FROM tblStudySiteImp
    WHERE (((tblStudySiteImp.StudyNo)=[Forms]![CboStudyNo].[Text]));

    but each time i select the value from the StudyNo box and click on the SiteNo i have to re-enter the StudyNo any ideal y ?

    I have attached the updated database.



    Originally posted by Norberto
    I send your Base with update
    Attached Files Attached Files
    Skharva

  11. #11
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    I send your Base with the upgrade
    Attached Files Attached Files
    Saludos
    Norberto

  12. #12
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Smile

    Thanks. This helps alot. But one more thing when i used the same query in Access2000 it doesn't wrk. Any reason why ?



    Originally posted by Norberto
    I send your Base with the upgrade
    Skharva

  13. #13
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Smile

    I figure out in Access2000

    Thanks alot


    Originally posted by Skharva
    Thanks. This helps alot. But one more thing when i used the same query in Access2000 it doesn't wrk. Any reason why ?
    Skharva

Posting Permissions

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