How to get the value from a listbox populated by a query in access 2007?
Hi, i have a listbox in a form populated with
————————————————————
SELECT DISTINCT tabla_proyecto.id_proyecto FROM tabla_proyecto, tabla_muestra WHERE tabla_proyecto.id=[Forms]![selecciona_proyecto]![txt_id];
————————————————————
This is a selection made in the welcome form that opens another more specific form; and it works cool. But now I put a button that triggers a query that creates a new record in a table, adding code to the button like so:
————————————————————————————————
Private Sub button_Click()
DoCmd.SetWarnings False
DoCmd.RunSQL “INSERT INTO tabla_analisis (id_proyecto, id_muestra, analisis, [metodos de analisis], [resultados del analisis elemental], [resultados del analisis], laboratorio) VALUES ( ’” & _
Forms!crea_analisis.id_proyecto.Value & ”’, ’” & _ <—this is a listbox
Forms!crea_analisis.id_muestra.Value & ”’, ’” & _ <—this is a listbox
Forms!crea_analisis.analisis & ”’, ’” & _ <—this is a textbox
Forms!crea_analisis.metodos & ”’, ’” & _ <—textbox
Forms!crea_analisis.elemental & ”’, ’” & _ <—textbox
Forms!crea_analisis.resultados_analisis & ”’, ’” & _ <—textbox
Forms!crea_analisis.laboratorio & ”’ );”
MsgBox “Nuevo Analisis ” & Me!id_muestra.Value & ” creado”
DoCmd.Close
End Sub
————————————————————————————————
The problem is that I cant get the value of the listboxes, Im trying different sintax, like
Me!id_muestra.SelectedItem(0).Value
but doesnt seem to work. what am I doing wrong here?
Composing members: 0