May 04 2022 08:48 AM
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 them, so I made separate Text boxes for each key number. So first key- 2nd key-3rd key and so forth. What I want to do is have that one listbox check if the first key box is empty. If it is, the key number goes there, if not, then it goes to text box 2, and so forth. The code I have is below, but it puts out a syntax error. I dont know what is wrong, as its been years since I've even looked at access. I'm not sure if I'm putting it in the wrong place (Under event procedure for the listbox)? Any help will be greatly appreciated :)
=iF IsNull(Key1) Then Key1 = ListBox ElseIf IsNull(text86) Then text86 = ListBox ElseIf IsNull(text103) Then text103 = ListBox ElseIf IsNull(text105) Then text105 End If
This brings back a invalid Syntax error
May 04 2022 01:20 PM
@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
May 04 2022 01:25 PM
Ok thank you so much. I will try that. I should be putting this under the listbox event correct?
May 04 2022 02:03 PM
May 05 2022 11:50 AM