MS ACCESS: Update textbox from parameter query

Viewed 87

I'm trying to update the value of a textbox from 2 different combbox in the form using a parameter query.

The query looks like this:

SELECT tblClubs_Equipos.ID FROM tblClubs_Equipos WHERE (((tblClubs_Equipos.idClubs)=[Forms]![frmPartidos]![cbClubLocal]) AND ((tblClubs_Equipos.idEquipos)=[Forms]![frmPartidos]![cbEquipoLocal]));

The textbox is named -> txtidEquipoLocal

I have created VBA event as follows:

Private Sub cbEquipoLocal_AfterUpdate()

txtidEquipoLocal.Requery

End Sub

Although I don't get any error the textbox shows #NAME?

Can anyone let me know what am i missing.

Kind Regards,

1 Answers

lets assume the following the name of the first combobox is combobox1 the name of the second combobox is combobox2 the name of the textbox is txtidEquipoLocal

All combo box have a property called column(0), column(1), etc if you want to access the first column(i.e first value from the left) in a combox you use combobox1.column(0)

So we need to update the value of the textbox control every time the two combo box values are updated.

Private Sub combobox1_AfterUpdate()

txtidEquipoLocal.text=combobox1.column(0)

End Sub

for the second combo box do the following

Private Sub combobox2_AfterUpdate()

txtidEquipoLocal.text=combobox2.column(0)

End Sub

i have assumed its the first value from the left of the combo boxes you want to assess, if its not, e.g second value, then you use combobox1.column(1), to assess combobox1's second value.

Your question is silent on whether you want to concatenate the values from the two combo boxes or you want to perform a calculation, so am unable to assist with that.

Related