Results 1 to 11 of 11
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help With Case Statement? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I have the following Case statement and can

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help With Case Statement? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    strAllInitials =

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help With Case Statement? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help With Case Statement? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    How about something like this:

    <code>
    Option Explicit

    Dim strInitials1 As String, strInitials2 As String, strInitials3 As String
    strInitials1 =
    Legare Coleman

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help With Case Statement? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Thanks for the suggestion

    My problem is that I a variable number of initials (1-15 sets) coming in from the following code that sits on top of my case statement:

    I probably need a different approach, load an array and step through it to validate the initials, or step through it to load

    Dim strInitials1 As String, strInitials2 As String, strInitials3 As String, etc

    As you suggested, in any event I could use some code.

    Thanks, John

    <pre>Dim strUserPasswords As String
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    </pre>


    <pre>If TableExists("tblCustCounter") = True Then 'Error 3078
    If FieldExists("tblCustCounter", "UserPasswords") Then 'Error 3265
    Set db = CurrentDb
    Set rst = db.OpenRecordset("tblCustCounter", dbOpenSnapshot)
    If rst.RecordCount = 0 Then
    MsgBox "There is no tblCustCounter record"
    Exit Function
    End If
    rst.MoveFirst
    strUserPasswords = rst!UserPasswords
    rst.Close ' Close recordset
    Set rst = Nothing ' Release recordset object
    Set db = Nothing ' Release database object
    End If
    End If
    </pre>


  6. #6
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help With Case Statement? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    In that case, I think you will have to do it in a loop rather than use a Case statement.
    Legare Coleman

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help With Case Statement? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Do you have any sample code to illustrate the concept?

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Help With Case Statement? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Would this be of help?
    <pre>Public Function Contains(ByVal varIn As Variant, _
    ParamArray varFind() As Variant) As Boolean
    'created by Charlotte Foust 2/3/2000
    Dim intLoop As Integer
    If Not IsNull(varIn) And _
    Not IsEmpty(varFind) Then
    For intLoop = 0 To UBound(varFind)
    If InStr(varIn, varFind(intLoop)) <> 0 Then
    Contains = True
    Exit For
    End If
    Next intLoop
    End If

    End Function</pre>

    Charlotte

  9. #9
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help With Case Statement? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help With Case Statement? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You should <big>NOT</big> put

    Dim strUserPasswords As String
    Dim strUserPassword As String
    strUserPasswords = "JBGETG"
    strUserPassword = "ETG"

    in the code of the Contains function. That defeats the purpose.

    To test, try for instance

    ? Contains("JBG,ETG", "ETG")

    (should return True), or

    ? Contains("JBG,ETG", "ETN")

    (should return False)

    In your code, you can use something like this:

    Dim strInitials As String
    dim strAllInitials as String
    strAllInitials = "PAR,MEP,SAG"
    strInitials = ...

    If Contains(strAllInitials, strInitials) = True Then
    MsgBox "2 OK"
    Else
    ...

  11. #11
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help With Case Statement? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Thank you Charlotte & Hans my code is running great

    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •