Select Case not opening forms

E

Emma

Hi there,

Can someone tell me why the following select case statement is not opening
the forms:

Private Sub Job_Type_AfterUpdate()

Select Case Form_Tbl_Master_Jobs!Job_Type
Case "New Contract"
DoCmd.GoToControl "Frame_Contract_Type"
Case "Debit Memo"
DoCmd.OpenForm "frm_Tbl_Credit_Details"
Case "Evaluation"
DoCmd.OpenForm "frm_Tbl_Evaluation_Details"
Case "Addendum"
DoCmd.OpenForm "frm_New_Addendum"
Case "Rental"
DoCmd.OpenForm "frm_Rental_Detail"
Case Else
DoCmd.GoToControl "Comments"
End Select

End Sub

Thank you!
 
M

mscertified

First, I'd make sure the case statements are being executed by putting a
msgbox under each one including the 'case else'.
Also before the 'select case', put the following
msgbox Form_Tbl_Master_Jobs!Job_Type

knowing how to debug problems generally is more valuable than getting the
answer to a specific problem.

-Dorian
 
E

Emma

Okay did that.

I have a total of 19 items in this drop down list of which only the items
listed below have forms that are supposed to open when selected.

When I put the msgbox before my select case statement and after each select
case and run it, 1) a msgbox appears with the number of my selection, but not
the msgbox for my selections below, then 2) a second msgbox appears for my
case else.

I gather that this is telling me that my select case is dropping down to my
case else and not even going to my selected select case statement? Why?
 
M

mscertified

Sounds like you are testing a numeric value (a code?) but checking for a text
value ("New Contract"). Hence it is skipping to the 'case else'.
The first msgbox should be displaying one of the text values you are
checking for

-Dorian
 
E

Emma

Okay, the light has gone on!! Thank you so much for your help. I changed
the select case identifier to the number of the selection instead of the
string and the select case is now opening my forms:

Private Sub Job_Type_AfterUpdate()

Select Case Me!Job_Type
Case 1 'Addendum
DoCmd.OpenForm ""
Case 5 'Evaluations
DoCmd.OpenForm "frm_Tbl_Evaluation_Details"
Case 7 'Contract Options
DoCmd.GoToControl "Frame_Contract_Type"
Case 8 'Rentals
DoCmd.OpenForm "frm_Rental_Detail"
Case 12 'debit memos
DoCmd.OpenForm "frm_Tbl_Credit_Details"
Case Else 'go to comments
DoCmd.GoToControl "Comments"
End Select

End Sub

Thank you!
 
E

Emma

Yeah, I finally got it, after I used your debug method. Thank you so much.

Can you tell me, though, how do I get the Job_ID (from my main form) over to
the form I am opening? In each of the forms that I am opening (opening in
Add mode) I have an FK_Job_ID field that needs to be populated automatically
when opening the form? Do I have to use the OpenArgs method or is there some
other way? Because it seems that unless that table on which the opening form
is based is populated, the form opens completely blank. I need it to open
with the fk_Job_ID field populated. I also have an account number field that
needs to be populated from the main form also.
 
M

mscertified

Yes, you could use the openargs parameter to pass the id.
You can read the openargs in the form open event and do what you want with it.
If it is the primary key of a record, you could even do a DLOOKUP or open a
recordset to get any other columns you need from the record. You can also
pass multiple values in the openargs either by separating each value with
some character (e.g. ";") or my declaring a custom type and passing a value
of the type.

-Dorian
 

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