Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case statement 1

Status
Not open for further replies.

ad2

Technical User
Dec 31, 2002
186
US
Hi,

I have two combo boxes on a search form. one that has a list of the subject IDs and the other that has a list of forms.

After the user choses the subject ID and then the form, I want the form to open to the record of the Subjct ID chosen.

I have the following code on the click event of the second combo box, the one that lists the forms but it isn't working. After a form is chosen from the list, a message diolog box pops up saying "The action or method requires a Form Name argument"

Any advise you could give would be great. Thanks!

<code>
Private Sub ComboFormList_Click()
On Error GoTo Err_ComboFormList_Click
Dim stDocName As String
Dim stLinkCriteria As String


Select Case Search
Case "frmPersonalInfo"
stDocName = "frmPersonalInfo"
Case "frmOrder"
stDocName = "frmOrder"
End Select

stLinkCriteria = "[SubID]=" & Me![SubID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_ComboFormList_Click:
Exit Sub

Err_ComboFormList_Click:
MsgBox Err.Description
Resume Exit_ComboFormList_Click

End Sub
</code>
 



Something like this...
Code:
Private Sub ComboFormList_Click()
On Error GoTo Err_ComboFormList_Click
Dim stDocName As String
Dim stLinkCriteria As String


Select Case [b]ComboFormList.Value[/b]
Case "frmPersonalInfo"
stDocName = "frmPersonalInfo"
Case "frmOrder"
stDocName = "frmOrder"
End Select

stLinkCriteria = "[SubID]=" & Me![SubID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_ComboFormList_Click:
Exit Sub


Skip,
[sub]
[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue][/sub]
 
Instead of using OnClick event, try using the OnChange event. With OnClick, the event is triggered as soon as the user clicks on the control - before the user can make a selection. Therefore, "Search" is null or "". You could verify this by stepping through your code in debug and watch "Search" or put a Case Else statement in your select that calls a know form - just to verify what is happening.

"Retired Programmer". So, please be patient.
 
What about this ?
Code:
Private Sub ComboFormList_Click()
DoCmd.OpenForm ComboFormList, , , "SubID=" & Me!SubID
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks SkipVought, works like a dream.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top