VBA Elseif command

gumbi17

Registered User.
Local time
Yesterday, 18:52
Joined
Aug 23, 2011
Messages
43
Alright I am still new to the VBA world but I am giving my coding a try, and so far it is no good. Here is the problem, I have a combo box that pulls down 36 different selections. Each of the 36 selections all have different responses and as well a different value. So if the user pulls down the first selection from cboCode then he will need to have it redirect the next combo box cboResponse to show from codes-Yes1 (Response column) and also have another combo box cboValue (Raw column) to show from Codes-Value1. I know this should be an easy but long If elseif statement but I am not doing as well I think with it or it least it doesn't look right and I want to be on the right path before wasting a ton of work.

If Me.cboCode = cboCode.Column(2)"1" Then
Me.cboResponse.RowSource = [codes-Yes]![Response]
Me.cboValue.RowSource = [code-Value1]![Raw]
Elseif
Me.cboCode = cboCode.Column(2)"2" Then

and etc.

End If
 
What is the "1" and the "2" for? That doesn't follow the syntax. Also, ElseIf should be one line, not two. Also, the way that you are setting the rowsource does not look right. Is codes- Yes a table? If so, you should rename your objects. No spaces and no special characters. I think the - is a special character. Most people use an underscore for a space if they really want one. If it is a table, you are referencing it wrong. It is more like Tables!codes-Yes!Response. I'm sure I'm wrong in that somewhere. I haven't touched Access in a long time.
 
The 1 and 2 are from the query that pulls the data for the combo box. The codes-Yes doesn't have a space but I see what your saying and the _ will work just the same. Thats the problem I am having from the table I am referencing for the command, do have it point towards the autonumber for the else command?
 

Users who are viewing this thread

Back
Top Bottom