Forum Discussion
Data2link
May 04, 2022Copper Contributor
If Statement on a list box?
Hello, Im hoping I can get some help with a statement I want to put on a list box. I am making a Key-checkout form. I have a listbox of key numbers. Employees can have more than one key assigned to t...
RichardRost
May 04, 2022MVP
Data2link Your syntax looks OK, provided you have the correct spacing and that's not all just on one line:
If X=1 Then
doThis
Elseif X=2 Then
doThis
Else
doThat
End If
Also, don't put an = sign in front of that. See these free videos for more help:
Richard Rost
MVP 2014-2015
- Data2linkMay 04, 2022Copper Contributor
Ok thank you so much. I will try that. I should be putting this under the listbox event correct?
- RichardRostMay 04, 2022MVPThe list box's AfterUpdate event, yes. And I'd rename the list box to something like KeyList, and name those text boxes something better as well. So you should end up with something like:
If IsNull(Key1) Then
Key1 = KeyList
Elseif IsNull(Key2) Then
Key2 = KeyList
Else
Key3 = KeyList
End If- Data2linkMay 05, 2022Copper ContributorOK thank you- I was putting it in the wrong place. Gonna give this a shot. (Great videos btw)