This is the data I have and nothing is added when I click Addtolist and don't understand why? Any help?
Private Sub Addtolist_Click()
vol_my_worked_hrs.RowSource = vol_my_worked_hrs.RowSource & MyText1 & MyText2 & ";"
End Sub
ijared
This is the data I have and nothing is added when I click Addtolist and don't understand why? Any help?
Private Sub Addtolist_Click()
vol_my_worked_hrs.RowSource = vol_my_worked_hrs.RowSource & MyText1 & MyText2 & ";"
End Sub
ijared
Add a debug.print line for the right side of the equals sign before that line.
Run the code and look at the result in the immediate window.
You should be able to see the reason from that.
If not paste the result into the listbox row source and view in the form
Probably should be:
Code:vol_my_worked_hrs.RowSource = vol_my_worked_hrs.RowSource & MyText1 & ";" & MyText2 & ";"
That's assuming it's a 2 column value list.
However if so, I think your semicolons are wrongly placed as there isn't one at the end of the 'list'
Of course if it's based on a table or query., that won't work at allCode:vol_my_worked_hrs.RowSource = vol_my_worked_hrs.RowSource & ";" & MyText1 & ";" & MyText2
I assumed that one was already there - and that's why I said probably.However if so, I think your semicolons are wrongly placed as there isn't one at the end of the 'list'
It's enough of a hint for the OP to figure it out...
I removed the & ";" & MyText1 & ";" & MyText2. Nothing happened.
Why did you remove that? And what does nothing happened mean?
I just tested this and it worked for me!Code:vol_my_worked_hrs.RowSource = vol_my_worked_hrs.RowSource & ";" & MyText1 & ";" & MyText2
You need the following for that code to work
a) listbox with row source = Value List
b) 2 columns
c) property 'Allow Value List Edits' set to Yes
d) listbox name is 'vol_my_worked_hrs'
Here's some alternative code that should also work
If you are still stuck, there lots of hits for this topic on Google. For example:Code:Me.vol_my_worked_hrs.AddItem MyText1 & ";" & MyText2
http://etutorials.org/Microsoft+Prod...+or+Combo+Box/
https://msdn.microsoft.com/en-us/vba...-method-access
Good luck
if its a value list you can use
Code:me.vol_my_worked_hrs.AddItem me.MyText1 me.vol_my_worked_hrs.AddItem me.MyText2
It should be noted that unless the Form has been opened in Design View, the additional items will only be added for the duration that the Form is open. When the Form is closed and then reopened, the new items will no longer be there.
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007
followed the links listed here. The listbox is still empty.Why did you remove that? And what does nothing happened mean?
I just tested this and it worked for me!Code:vol_my_worked_hrs.RowSource = vol_my_worked_hrs.RowSource & ";" & MyText1 & ";" & MyText2
You need the following for that code to work
a) listbox with row source = Value List
b) 2 columns
c) property 'Allow Value List Edits' set to Yes
d) listbox name is 'vol_my_worked_hrs'
Here's some alternative code that should also work
If you are still stuck, there lots of hits for this topic on Google. For example:Code:Me.vol_my_worked_hrs.AddItem MyText1 & ";" & MyText2
http://etutorials.org/Microsoft+Prod...+or+Combo+Box/
https://msdn.microsoft.com/en-us/vba...-method-access
Good luck
I
This should help you see what's going on and whether you need the additional ";" before MyText1
Code:Private Sub Addtolist_Click() Dim NewList as string msgbox "MyText1=" & myText1 & vbcrlf _ & "MyText2=" & myText2 & vbcrlf _ & "vol_my_worked_hrs.RowSource=" & vol_my_worked_hrs.RowSource NewList = vol_my_worked_hrs.RowSource & MyText1 & "," & MyText2 & ";" msgbox "NewList=" & NewList vol_my_worked_hrs.RowSource = NewList End Sub
What exactly is it you are trying to do?
Is the listbox query based or a value list?
do you have your column counts and column widths set correctly?
show the code for what you have tried.
This is the data I have and nothing is added when I click Addtolist and don't understand why? Any help?
Private Sub Addtolist_Click()
vol_my_worked_hrs.RowSource = vol_my_worked_hrs.RowSource & MyText1 & MyText2 & ";"
End Sub