Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 31
  1. #16
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    hammer187 - If its the code I provided

    Try adding:
    DeBug.Print CoachID(iCounter)
    'before the line
    'If CoachID(iCounter) = txtID then

    Jim

  2. #17
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    No change Jim.

  3. #18
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    Here is the code that I am using

    Code:
    Private Sub Command12_Click()
       
       
    Dim txtID As Variant
    txtID = Forms![LoginForm1]![txtEmployeeID]
    If Len(txtID) > 0 Then
    Dim CoachID() As Variant
    ReDim CoachID(1 To 7) As Variant
    CoachID(1) = “10269443”
    CoachID(2) = “10440457”
    CoachID(3) = "10269343"
    CoachID(4) = "10269343"
    CoachID(5) = "01604737"
    CoachID(6) = "01654817"
    CoachID(7) = "10391316"
    Dim intC As Integer
    intC = UBound(CoachID)
    Dim iCounter As Integer
    iCounter = 1
    Do Until iCounter = intC
    Debug.Print CoachID(iCounter)
    If CoachID(iCounter) = txtID Then
    DoCmd.OpenForm "frmMain", acNormal
    Exit Do
    End If
    Debug.Print iCounter
    iCounter = iCounter + 1
    Loop
    DoCmd.OpenForm "HourlyForm", acNormal
    Else
    MsgBox "Please enter a valid Associate ID"
    End If
    End Sub

  4. #19
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    hammer187 -

    Try this...
    Dim txtID As Variant
    txtID = Forms![LoginForm1]![txtEmployeeID]
    'Add
    MsgBox txtID
    'See what is returned

    Jim

  5. #20
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    It displays the correct number but it doesnt check the array for that number I dont think.

  6. #21
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    I am going to leave to go home from work. Keep giving me ideas or snippets. I will test them when I get home, which will be an hour. Thank you.

  7. #22
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    In which case...

    I would check the value of the Debug.Print CoachID(iCounter)
    dim x as Variant
    x = Debug.Print CoachID(iCounter)
    MsgBox x

    and, lastly I would check to see if the number returned from the previous MsgBox was in the array values stipulated.

    Jim

  8. #23
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I would love to hear why you want to do this the hard way. I would point out that as written, the HourlyForm will open no matter what. It would be easier for Jim to debug if you could post the db here.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #24
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    Paul - Thank you for point out the hourly form oversight. Your help is much appreciated. Jim

  10. #25
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem Jim.

    <Soapbox>
    I just don't like using an array for this. It's basically putting business logic in code that belongs in a table. You shouldn't have to change the design of the application when you get a new employee, which this will require. Arrays are wonderful tools, just not the correct tool for this job in my opinion.
    </Soapbox>
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #26
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I tested your code.
    You have some illegal quotes in these

    Code:
    CoachID(1) = “10269443” 
    CoachID(2) = “10440457”
    I changed the quotes and commented a few lines and the code ran and executed the "open Form " line.
    There may be more, but that is what I found.


    You need to use the proper delimiter "

  12. #27
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    Paul/Orange - Please look at the "not so elegant" revised code below...

    Private Sub Command12_Click()
    Dim txtID As Variant
    txtID = Forms![LoginForm1]![txtEmployeeID]

    If Len(txtID) > 0 Then
    Dim CoachID() As Variant
    ReDim CoachID(1 To 7) As Variant
    CoachID(1) = "10269443"
    CoachID(2) = "10440457"
    CoachID(3) = "10269343"
    CoachID(4) = "10269343"
    CoachID(5) = "01604737"
    CoachID(6) = "01654817"
    CoachID(7) = "10391316"
    Dim intC As Integer
    intC = UBound(CoachID)
    Dim iCounter As Integer
    iCounter = 1
    Dim Switch as Integer
    Switch = 1
    Do Until iCounter = intC
    Debug.Print CoachID(iCounter)
    If CoachID(iCounter) = txtID Then
    DoCmd.OpenForm "frmMain", acNormal
    Switch = 2
    Exit Do
    End If
    Debug.Print iCounter
    iCounter = iCounter + 1
    Loop
    If Switch = 1 then
    DoCmd.OpenForm "HourlyForm", acNormal
    End if
    Else
    MsgBox "Please enter a valid Associate ID"
    End If
    End Sub


    At this point, I'm just trying to get it to work.


    Jim

    PS - The quotes were a result of copying/pasting.
    Last edited by ketbdnetbp; 08-30-2012 at 04:31 PM. Reason: quotes

  13. #28
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    That last code worked great. I would love to do it the easy, dynamic way with a table. But like I said in my first post, I am not good with access. That is why I had this forum to help me with this array. Thank you Jim

  14. #29
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    hammer187 -

    Very glad it is working. However, as Paul suggested, when a change occurs, records added/deleted, etc. in the employee table, the code would have to be updated. If you can provide details of the employee table, I/we might be able to help you with a dynamic solution.

    As always, thanks to Paul and Orange for their assistance.

    Jim

  15. #30
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    I am totally fine with updating the code everytime a change occurs. I was going to copy and paste my esleif statements anyway with the code that I had written. This just helped me scratch out a step.

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Inputing Checks
    By bornstein.a in forum Access
    Replies: 1
    Last Post: 08-27-2012, 04:29 PM
  2. Having Trouble Returning Array from Function
    By NigelS in forum Programming
    Replies: 8
    Last Post: 08-15-2011, 07:12 AM
  3. Disappearing checks in check boxes
    By jimmonator in forum Forms
    Replies: 3
    Last Post: 07-21-2011, 02:57 PM
  4. Having trouble with Next Number
    By WyzrdX in forum Programming
    Replies: 2
    Last Post: 12-17-2010, 12:17 PM
  5. Insert Record checks table
    By pfarnell in forum Forms
    Replies: 13
    Last Post: 09-05-2010, 10:47 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums