Help with code

J

Jennifer

I have a combo box with differnet values. If one of the values is selected
then part of the form will populate. But the other values have no effect.

This is the start

If Me.cmbChangeRequestType.Value = "Add/Rem" Then
(Code to populate)

I want to start the next part if the Value "Information" is selected. I am
okay with getting the fields in there but don't know how to start the next
"section".
 
D

Dirk Goldgar

Jennifer said:
I have a combo box with differnet values. If one of the values is selected
then part of the form will populate. But the other values have no effect.

This is the start

If Me.cmbChangeRequestType.Value = "Add/Rem" Then
(Code to populate)

I want to start the next part if the Value "Information" is selected. I
am
okay with getting the fields in there but don't know how to start the next
"section".


If -- and it's a big if -- I understand what you are getting at, then you
could write it either of two ways. One is to use the "ElseIf" statement in
your If ... End If block:

If Me.cmbChangeRequestType.Value = "Add/Rem" Then
' ... code for "Add/Rem" case ...
ElseIf Me.cmbChangeRequestType.Value = "Information" Then
' ... code for "Information" case ...
Else
' ... code for any all unspecified cases (if any) ...
End If

A somewhat cleaner way to code it, so long as all the cases are based on
possible values of the combo box, is to use the "Select Case" construct:

Select Case Me.cmbChangeRequestType.Value
Case "Add/Rem"
' ... code for "Add/Rem" case ...
Case "Information"
' ... code for "Information" case ...
Case Else
' ... code for any all unspecified cases (if any) ...
End Select
 
A

Allen Browne

Perhaps you could use Select Case:

Select Case Me.cmbChangeRequestType.Value
Case "Add/Rem"
'code to populate
Case "Information"
'code to populate
Case Else
'code to populate
End Select
 

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