Results 1 to 4 of 4
  1. #1
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64

    Make Toggle Button enter data on press and delete data on unpress


    I'm trying to work with a toggle button to enter a date into a table when pressed and delete that date if unpressed. I wish I could tie a macro into the state of the toggle button, but it seems I just have to use the On Click event with an if/then macro hoping that the button condition and cell condition don't get out of sync. However, trying to write a macro to handle this doesn't seem to be working. Below is what I've written. I don't get an error. It just doesn't seem to do anything.

    Code:
    Private Sub Toggle96_Click()
    If Me.Frame_Stripped = Null Then
    Me.Frame_Stripped = Date
    Else: Me.Frame_Stripped = Null
    End If
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Can't test for null with = null. Review http://allenbrowne.com/casu-12.html

    If IsNull(Me.Frame_Stripped) Then
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Historypaul View Post

    ...hoping that the button condition and cell condition don't get out of sync...
    As for being sure that you're doing this to the Record you intended to do it do, instead of using a Toggle, I'd use the DoubleClick event of the Control for the Date Field. That way you'll know which Record you're working with...no guessing!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64
    Thanks, June7. I knew it had to be something simple I missed. I read the reference you gave me. Your advice got the first part of the macro to work, but I think I was mistaken on how the toggle button reacts period. I had it linked to a query and maybe because it wasn't updating the table, it wouldn't stay down even when there was data in the table. Now that I linked it directly to a table, it stays down - doesn't come back up unless you delete the value from the table. I ended up using the double click event to clear the data from the table, which resets the toggle button.

    - Missinglinq - That is a great idea, but I don't actually want the user to see that this action is entering a date. I'm using a multiple items form and so far, I haven't seen anything that would make me worry about the control not associating with the right record. My "getting out of sync" concern was due to the toggle button going up or down with each press regardless of whether there was data in the cell or not when I was testing it out linked to a query...

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

Similar Threads

  1. Replies: 1
    Last Post: 07-16-2012, 02:10 PM
  2. Can't use data access pages to enter data
    By ellie1 in forum Access
    Replies: 2
    Last Post: 04-21-2012, 12:32 AM
  3. Replies: 4
    Last Post: 02-27-2012, 10:29 AM
  4. Press a button to combine two fields to open a PDF
    By Douglas Post in forum Programming
    Replies: 4
    Last Post: 02-11-2012, 02:02 PM
  5. Replies: 0
    Last Post: 11-22-2011, 09:10 PM

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