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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch error problem 1

Status
Not open for further replies.

mguidry5

Technical User
Jan 11, 2005
91
US
Hi,

I've got some code that's giving me problems. I'm allowing priviledged users the ability to modify some table content via datasheet forms. The tables are used as combo box data sources throughout the database.

I've given them a combo box (cboLists) to select the pick list (table) that they would like to modify the contents of, and a command button to open the selected pick list modification form. cboLists is based on a table with two fields: Form and Description (both text fields). cboLists shows the user the description, but not the form name to be opened.

What I'd like to do is prompt the user with a simple messagebox if they open a certain form. I'm getting a type mismatch error with this code:
Code:
Private Sub cmdModifyList_Click()
On Error GoTo Err_cmdModifyList_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = Me.cboLists
    
    If Me.cboLists = "frmListAgencies" Or "frmListChemicals" Then
        MsgBox "This list should only be modified by EHS personnel.", vbExclamation + vbOKOnly
    ElseIf Me.cboLists = "frmListEmployees" Then
        MsgBox "This list should only be modified by Human Resources personnel.", vbExclamation + vbOKOnly
    Else
        'Do nothing
    End If
    
    DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria, , acDialog
    Me.cboLists = ""

Exit_cmdModifyList_Click:
    Exit Sub

Err_cmdModifyList_Click:
    MsgBox Err.Description
    Resume Exit_cmdModifyList_Click
    
End Sub

Any ideas why I'm getting this error?
 
This

[tt]If Me.cboLists = "frmListAgencies" Or "frmListChemicals" Then[/tt]

is doing a comparision of sorts, but you're probably more interested in

[tt]If Me.cboLists = "frmListAgencies" Or Me.cboLists = "frmListChemicals" Then[/tt]

But - please also say on which line the error occurs ...

Perhaps also ensure there is a selection in the combo?

Roy-Vidar
 
RoyVidar,

Thanks - that does the trick. Sorry I forgot to say which line the error was on, but you got it.

If I don't make a selection in the combo, it gives me a default message that is adequate for my purposes.

Thanks again,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top