Results 1 to 4 of 4
  1. #1
    Dominaz is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    21

    Each time I click run different code

    Hello,



    I would like to know how can I code, an event in a textbox, so each time I click on it, a different option appears in it.
    I know how to give a value to the textbox for the first click (Forms!frmCalendar!txtDayBlock01.Value = "yes"), but no idea how to change this value after each click.....

    Let's say:

    I've text box , on click event once I want to appear "Yes", on click the second time "No", third click "Maybe", Forth "No way", and then fifth will start again with "Yes".


    Thanks

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    In your On Click event, you can put code in that first of all reads what is currently in the Text Box.

    Then - depending on what is in the Text Box currently, decide what to put in there next.

    Eg [not tested]:
    Code:
     
    Text1.SetFocus()
    If Text1.Text = "Yes" Then
        Text1.Text = "No"
    Else If
        Text1.Text = "No" Then
    Text1.Text = "Maybe"
        ' . . . more options here
    End If
    Hope this helps!
    Last edited by Robeen; 11-10-2011 at 10:44 AM. Reason: Incomplete instructions.

  3. #3
    Dominaz is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    21
    Hello, Here I show you my Code,

    The problem is that in the First Click it change to Not Available, in the second one it goes to AM.. but thats it...
    It doesn't change to PM ,and it stays in AM...

    (The text box has the value 1 the first time I click)

    If Forms!frmCalendar!txtDayBlock01.Value Like " 1*" Then


    Forms!frmCalendar!txtDayBlock01.Value = "Not Available"
    Me.ActiveControl.BackColor = 16777165

    ElseIf Forms!frmCalendar!txtDayBlock01.Text Like "[Not Available]*" Then
    Forms!frmCalendar!txtDayBlock01.Value = "Available AM"
    ElseIf Forms!frmCalendar!txtDayBlock01.Text Like "Available AM*" Then
    Forms!frmCalendar!txtDayBlock01.Value = "Available PM"
    ElseIf Forms!frmCalendar!txtDayBlock01.Text Like "[Available PM]*" Then
    Forms!frmCalendar!txtDayBlock01.Value = "Available"
    ElseIf Forms!frmCalendar!txtDayBlock01.Value Like "[Available]*" Then
    Forms!frmCalendar!txtDayBlock01.Value = "Not Available"


    End If


    So, What Could I do?? I don't know why it does Not Available, Available AM, and it doesn't continue....

    Thank you.

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Put a Break Point in your code on this line:
    Code:
     
    If Forms!frmCalendar!txtDayBlock01.Value Like " 1*" Then
    Now - when you run your Click event - when the code sees txtDayBlock01.Text Like "Available AM*"
    it will stop and take you to that line of the code.
    Once you're in the code in Break mode - you can see what your variables are by holding your mouse pointer over the variable name in the code.

    You might be able to find the problem by this method of debugging.
    This is a good way to learn how to spot problems in your code.

    Let me know if you still have problems.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 08-04-2011, 07:49 PM
  2. Replies: 4
    Last Post: 07-22-2011, 12:52 PM
  3. Replies: 12
    Last Post: 02-22-2011, 03:39 PM
  4. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  5. Duplicate Check code with Run-Time error '3079'
    By viper in forum Programming
    Replies: 5
    Last Post: 10-18-2010, 10:12 AM

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