Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to VBA, calling array variables in Access

Status
Not open for further replies.

galorin

MIS
Nov 22, 2007
154
GB
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.
 

I can 't see what you are trying to do, but I think you should post in forum705 explaining a bit more what you have in mind and red flag this post for deletion as wrong forum posting
 
we need more info,

is this a bound form? What is the rowsource of your combo box? What are the names of the form controls you want to update?

JK


.....
I'd rather be surfing
 




Either
Code:
Dim field([red][b]5[/b][/red]) 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"
or
Code:
Dim field() As String
Dim x As Integer
Dim name1 As String
[red][b]
Redim field(5)[/b][/red]
field(0) = "ParentCompany"
field(1) = "Address1"
field(2) = "Address2"
field(3) = "Address3"
field(4) = "City"
field(5) = "Postcode"


Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top