View Full Version : If statement


Angello Pimental
06-15-2001, 10:48 AM
Could someone point me in the right direction concerning If statements.

I want to be able to assign a record a SortID# dependent on what value a user selects in a combobox.

For example, if a user selects:
Generic, the record is assigned SortID #1
UK, the record is assigned SortID #2
Japan, the record is assigned SortID #3

Does anyone know how I can do this using an If statment??

Thnx, Angelo


[This message has been edited by Angello Pimental (edited 06-15-2001).]

charityg
06-15-2001, 11:12 AM
If I have more than two different "rules" I use a select case statement.

Afterupdate of cbo
select case cboName
case "Generic"
sortID=1
case "UK"
sortID=2
case "Japan"
sortID=3
end select

BUT...

If each row of your combobox is associated with a different SortID number, why not add a hidden column to the combobox that contains the sortID number and reference it that way?

Say the sortID column is the second column, you could reference by using cboName.column(1)

OR you could save the value back to the underlying table with

cboName_AfterUpdate
sortID=me!cboName.column(1)

Does this make sense? Or did I fly off on a tangent. Just trying to make things easier for you!!

http://www.access-programmers.co.uk/ubb/smile.gif Charity

Angello Pimental
06-18-2001, 06:34 AM
Thankyou Charity,
Your suggestion worked perfectly!

Cheers,
Angelo