May 28 2024 01:00 PM
In a form, I have a combo box that changes dynamically, i.e., during execution each time I select it. Everything works fine except for the DropDown, which does not "auto-expand." I am sending the code I am using, thanks
Option Compare Database
Dim Seleccion As Integer
Const MarcaSQL1 As String = "SELECT pres_marca.Marca FROM pres_marca;"
Const MarcaSQL2 As String = "SELECT pres_modelo.Descripcion FROM pres_modelo WHERE (((pres_modelo.marca)=[textomarca]));"
Const MarcaSQL3 As String = "SELECT pres_cisterna.descripcion, pres_cisterna.Marca FROM pres_cisterna WHERE (((pres_cisterna.Marca) = [Textomarca])) ORDER BY pres_cisterna.Cisterna;"
Private Sub Form_Current()
Seleccion = 1
Caracteristicas.RowSource = MarcaSQL1
Caracteristicas.Requery
End Sub
Private Sub Caracteristicas_AfterUpdate()
If Seleccion = 1 Then
Textomarca = Caracteristicas
Seleccion = 2
Caracteristicas.RowSource = MarcaSQL2
Caracteristicas.RowSourceType = "Table/Query"
Caracteristicas.Dropdown
ElseIf Seleccion = 2 Then
Textomodelo = Caracteristicas
Seleccion = 3
Caracteristicas.RowSource = MarcaSQL3
Caracteristicas.Requery
Caracteristicas.Dropdown
ElseIf Seleccion = 3 Then
TextoCisterna = Caracteristicas
Seleccion = 1
Caracteristicas.RowSource = MarcaSQL1
Caracteristicas.Requery
Caracteristicas.Dropdown
End If
End Sub
May 29 2024 06:37 AM
Jun 22 2024 12:05 AM
@aramirezferrer i would utilize the Timer Event to change the recordsource.