Hi. New member here
Im sat at work, pounding my head off the desk because this tiny bit of simple code refuses to work.
The sub is intended to pull data from the "companynam e" column in the "cmSelectAllCom panyNames" table, and put all the company names it finds into the "cbFilterCompan yName" combo box.
Now the confusing aspect is this:
It works!!!
But only when:
I comment out the line "cbFilterCompan yName.AddItem (name, count)"
And then un-comment the line "MsgBox (name)".
Obviously the code "MsgBox (name)" is intended as a test.
And the test works. It shows that the company names are being pulled one after another from companyname column in the correct table, and being placed into the string called "name".
Now if I comment the line "MsgBox (name)" out. The entire thing stops working and pulls up an error at the line "deSQL.rscmSele ctAllCompanyNam es.MoveNext".
Everytime I get an error is shows up as being from that line of code.
So it shows that the code works and it is putting company names into the string called "name".
*dances*
The other issue is that it refuses to put the value inside "Name" into the combo box.
When I typed out the combobox name and add the *.additem section, it then shows me that I need to enter the values *.additem.(item as string, [index])!
So I added them as such *.additem(name, count).
Count being the incremement to move onto the next index.
It refuses to work that way.
Even if I remove the brackets and the word count, it still doesnt work.
My code:
Private Sub populateComboBo xes()
Dim name As String
Dim count As Integer
count = 0
'go to first value in companyname
deSQL.rscmSelec tAllCompanyName s.MoveFirst
'while not end of file
While (deSQL.rscmSele ctAllCompanyNam es.EOF) = False
'if companyname is null
If (deSQL.rscmSele ctAllCompanyNam es!companyname = Null) Then
name = "--No name--"
Else
'give name value in companyname
name = deSQL.rscmSelec tAllCompanyName s!companyname
'test
'MsgBox (name)
'populate combobox companyname
cbFilterCompany Name.AddItem (name, count)
End If
'incrememnt count tester
'count = count + 1
'move to next companyname
deSQL.rscmSelec tAllCompanyName s.MoveNext
Wend
MsgBox (count & " companies added to combobox")
End Sub
Summary:
Why does it stop working when I remove the code "MsgBox (name)"? At which point it complains about null values.
Why will it not populate the combobox using additem in the way its telling me to?
What do I need to change to make it enter the value in "name" into the combobox, and then incremement onto the next index in that combobox, ready for the next value?
Cheers
Im sat at work, pounding my head off the desk because this tiny bit of simple code refuses to work.
The sub is intended to pull data from the "companynam e" column in the "cmSelectAllCom panyNames" table, and put all the company names it finds into the "cbFilterCompan yName" combo box.
Now the confusing aspect is this:
It works!!!
But only when:
I comment out the line "cbFilterCompan yName.AddItem (name, count)"
And then un-comment the line "MsgBox (name)".
Obviously the code "MsgBox (name)" is intended as a test.
And the test works. It shows that the company names are being pulled one after another from companyname column in the correct table, and being placed into the string called "name".
Now if I comment the line "MsgBox (name)" out. The entire thing stops working and pulls up an error at the line "deSQL.rscmSele ctAllCompanyNam es.MoveNext".
Everytime I get an error is shows up as being from that line of code.
So it shows that the code works and it is putting company names into the string called "name".
*dances*
The other issue is that it refuses to put the value inside "Name" into the combo box.
When I typed out the combobox name and add the *.additem section, it then shows me that I need to enter the values *.additem.(item as string, [index])!
So I added them as such *.additem(name, count).
Count being the incremement to move onto the next index.
It refuses to work that way.
Even if I remove the brackets and the word count, it still doesnt work.
My code:
Private Sub populateComboBo xes()
Dim name As String
Dim count As Integer
count = 0
'go to first value in companyname
deSQL.rscmSelec tAllCompanyName s.MoveFirst
'while not end of file
While (deSQL.rscmSele ctAllCompanyNam es.EOF) = False
'if companyname is null
If (deSQL.rscmSele ctAllCompanyNam es!companyname = Null) Then
name = "--No name--"
Else
'give name value in companyname
name = deSQL.rscmSelec tAllCompanyName s!companyname
'test
'MsgBox (name)
'populate combobox companyname
cbFilterCompany Name.AddItem (name, count)
End If
'incrememnt count tester
'count = count + 1
'move to next companyname
deSQL.rscmSelec tAllCompanyName s.MoveNext
Wend
MsgBox (count & " companies added to combobox")
End Sub
Summary:
Why does it stop working when I remove the code "MsgBox (name)"? At which point it complains about null values.
Why will it not populate the combobox using additem in the way its telling me to?
What do I need to change to make it enter the value in "name" into the combobox, and then incremement onto the next index in that combobox, ready for the next value?
Cheers
Comment