View Full Version : case choice statement not working, please help


KevinSlater
08-08-2005, 03:14 AM
Hi, im trying create a form that promts the user with a message box that says "enter form name", from this if the user types "A" then form A will be opened for the user to add data into or if the user types in "B" then form B will be opened for the user to add data into.

Tables A & B are both emty to start of with. The field names in both tables are: user_id, firstname, lastname, date

I have created a third form to use for the person to make their choice. On that form I have a combo box. In th properties ive called it CmbSelect. In the data properties for the box i have changed it to "value list" & enterered forma;formb in the row for the list of values and have put the following code, in the after update property:

select case (cmbSelect)
case A
docmd.openform "formA"
case B
docmd.openform "formB"
case else
end select

but at present nothing happens when you try selecting a form from the drop down menu, any ideas what im doing wrong? Please help

Oldsoftboss
08-08-2005, 03:42 AM
If you have entered forma;formb in the row for the list of values then the select case should be:

select case (cmbSelect)
case forma
docmd.openform "formA"
case formb
docmd.openform "formB"
case else
end select

Dave

Oldsoftboss
08-08-2005, 03:43 AM
If you have entered forma;formb in the row for the list of values then the select case should be:

select case (cmbSelect)
case forma
docmd.openform "formA"
case formb
docmd.openform "formB"
case else
end select

Dave

KevinSlater
08-08-2005, 04:03 AM
Thanks for your reply that helps, but still nothing happens, yes forma;formb is in the list of values & the code is in the after update bit, the forms are named "forma & formb" any other suggestions?

dan-cat
08-08-2005, 05:32 AM
Thanks for your reply that helps, but still nothing happens, yes forma;formb is in the list of values & the code is in the after update bit, the forms are named "forma & formb" any other suggestions?


select case (cmbSelect)
case "forma"
docmd.openform "formA"
case "formb"
docmd.openform "formB"
case else
end select

Rich
08-08-2005, 05:50 AM
Why do you have two tables with an identical structure and field names?
Date is a reserved word in Access and should not be used as a field name

Oldsoftboss
08-10-2005, 02:23 AM
Instead of using a select case, for the moment, replace it with a Message Box

Msgbox cmbSelect

This will at least tell you what the combo box is returning. I feel the issue may be with the setup of the combo box.

Dave

KevinSlater
08-10-2005, 03:55 PM
Ok good idea, I will try that, thanks