Following is one iteration of the VBA code I am trying to use to update multiple fields after making a combo box selection in Access. I am not sure if what I want to do can be done in VBA or if I am still thinking in other languages.
Option Compare Database
Private Sub Company_AfterUpdate()
Dim field() As String
Dim x As Integer
Dim name1 As String
field(0) = "ParentCompany"
field(1) = "Address1"
field(2) = "Address2"
field(3) = "Address3"
field(4) = "City"
field(5) = "Postcode"
For x = 0 To 5
name1 = field(x)
Me.Eval(name1) = Null
Me.Eval(name1).Requery
Me.Eval(name1) = Me.Eval(name1).ItemData(0)
Next x
End Sub
I hope you can see what I am trying to do, have an array/collection/other list of values that can be passed into the me.$COMBOBOX field. This would allow a selection made in the main combo box to populate the rest of the information for that entry. I can do it for each entry, but it is not as easily maintained or re-usable.
Option Compare Database
Private Sub Company_AfterUpdate()
Dim field() As String
Dim x As Integer
Dim name1 As String
field(0) = "ParentCompany"
field(1) = "Address1"
field(2) = "Address2"
field(3) = "Address3"
field(4) = "City"
field(5) = "Postcode"
For x = 0 To 5
name1 = field(x)
Me.Eval(name1) = Null
Me.Eval(name1).Requery
Me.Eval(name1) = Me.Eval(name1).ItemData(0)
Next x
End Sub
I hope you can see what I am trying to do, have an array/collection/other list of values that can be passed into the me.$COMBOBOX field. This would allow a selection made in the main combo box to populate the rest of the information for that entry. I can do it for each entry, but it is not as easily maintained or re-usable.