End If without block if

  • Thread starter P-chu via AccessMonster.com
  • Start date
P

P-chu via AccessMonster.com

A little assistance. Getting an error end if without block if. This is
based on the selection of the account number assigned to a particular set of
3 states. So if the combo box selection for AcctNum is 20, then I want the
combo box of the state Name to equal that number assigned to it.

Private Sub cbxAcctNum_AfterUpdate()

If Me!cbxAcctNum = "20" Then Me!cbxName = "Maryland"
If Me!cbxAcctNum = "35" Then Me!cbxName = "Illinois"
If Me!cbxAcctNum = "40" Then Me!cbxName = "Texas"


End If
End If
End If

End Sub

Thank you.
 
A

Albert D. Kallal

the syntax is:

a)

if <condition> then one line

or

b)

if <condition> then
as many lines of code
end if

You syntax is of type a...and thus you do NOT need the end if's...
Private Sub cbxAcctNum_AfterUpdate()

iIf Me!cbxAcctNum = "20" Then Me!cbxName = "Maryland"
If Me!cbxAcctNum = "35" Then Me!cbxName = "Illinois"
If Me!cbxAcctNum = "40" Then Me!cbxName = "Texas"

End Sub

Try the above...it should compile.....
 
P

P-chu via AccessMonster.com

Thank you, it worked perfectly.
the syntax is:

a)

if <condition> then one line

or

b)

if <condition> then
as many lines of code
end if

You syntax is of type a...and thus you do NOT need the end if's...
Private Sub cbxAcctNum_AfterUpdate()

iIf Me!cbxAcctNum = "20" Then Me!cbxName = "Maryland"
If Me!cbxAcctNum = "35" Then Me!cbxName = "Illinois"
If Me!cbxAcctNum = "40" Then Me!cbxName = "Texas"

End Sub

Try the above...it should compile.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top