M
Mark
Hello,
I have a list box which I am populating through code. Trouble is, the
columns of data seem mixed up and I can't work out why.
The VBA code I have is as follows:
Dim myDB As DAO.Database
Dim mySet As DAO.Recordset
Dim varSQL As String
cboSites.RowSourceType = "Value List"
cboSites.RowSource = ""
cboSites.RowSource = "0,<USE MAIN>,x,x,x,x,x;"
varSQL = "Select CustomerID, SiteName, Add1, Add2, Add3, TownCity, PostCode
from tblAddresses Where CustomerID = " & CLng(cboCompany)
Set myDB = CurrentDb
Set mySet = myDB.OpenRecordset(varSQL)
If mySet.EOF = True Then
'there are no multiple Addresses so nowt to do
Else
mySet.MoveLast
X = mySet.RecordCount
mySet.MoveFirst
For i = 0 To X - 1
cboSites.RowSource = cboSites.RowSource & mySet.Fields("CustomerID")
& " ," & mySet.Fields("SiteName") & " ," & mySet.Fields("Add1") & " ," &
mySet.Fields("Add2") & " ," & mySet.Fields("Add3") & " ," &
mySet.Fields("TownCity") & " ," & mySet.Fields("PostCode") & ";"
mySet.MoveNext
Next
cboSites.Visible = True
End If
HELP!! Where is it going wrong??
The Column Count property is 7. Am I missing something.
I have a list box which I am populating through code. Trouble is, the
columns of data seem mixed up and I can't work out why.
The VBA code I have is as follows:
Dim myDB As DAO.Database
Dim mySet As DAO.Recordset
Dim varSQL As String
cboSites.RowSourceType = "Value List"
cboSites.RowSource = ""
cboSites.RowSource = "0,<USE MAIN>,x,x,x,x,x;"
varSQL = "Select CustomerID, SiteName, Add1, Add2, Add3, TownCity, PostCode
from tblAddresses Where CustomerID = " & CLng(cboCompany)
Set myDB = CurrentDb
Set mySet = myDB.OpenRecordset(varSQL)
If mySet.EOF = True Then
'there are no multiple Addresses so nowt to do
Else
mySet.MoveLast
X = mySet.RecordCount
mySet.MoveFirst
For i = 0 To X - 1
cboSites.RowSource = cboSites.RowSource & mySet.Fields("CustomerID")
& " ," & mySet.Fields("SiteName") & " ," & mySet.Fields("Add1") & " ," &
mySet.Fields("Add2") & " ," & mySet.Fields("Add3") & " ," &
mySet.Fields("TownCity") & " ," & mySet.Fields("PostCode") & ";"
mySet.MoveNext
Next
cboSites.Visible = True
End If
HELP!! Where is it going wrong??
The Column Count property is 7. Am I missing something.