Forum Discussion
Infopath question in regards to creating rules (contains)
I think you need to connect code to the after_update event.
You could run for every field you need
me.FldAdress.text = dlookup("Adress" ,"TblSuppliers" ,"ID=" &me. cmboOfSupplier.value
me.FldPlace.text = dlookup("Place" ,"TblSuppliers" ,"ID=" &me. cmboOfSupplier.value
I think this is most easy to understand but creates for every field a run on the database.
Other option is to extend the combo where you select the supplier with more columns and make them invisible with 0cm width and point to them with VBA with the after_update event.
Third option is to open a recordset with VBA and collect the needed fields.
Dim dbs As DAO.Database
Dim rsSQL As DAO.Recordset
Dim strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT * FROM tblSuppliers WHERE ID =" & me.cmboSupplier.value
Set rsSQL = dbs.OpenRecordset(strSQL, dbOpenSnapshot)
if rsSQL.recordcount > 0 then
rsSQL.movefirst
me.fldAdress.text = rsSQL!Adress
me.fldPlace.text = rsSQL!Place
' and so on
end if
rsSQL.close
Set rsSQL = nothing