Page 3 of 3 FirstFirst 123
Results 31 to 43 of 43
  1. #31
    Collins is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    107
    Quote Originally Posted by June7 View Post
    If Me.control.DefaultValue = "" Then
    Me.control.DefaultValue = Me.control


    Else
    Me.control.DefaultValue = ""
    End If

    Maybe use a Toggle button instead of Command button.

    If Me.toggle Then
    Me.control.DefaultValue = Me.control
    Else
    Me.control.DefaultValue = ""
    End If
    This is awesome June thanks... But I am trying to learn VB so as I see code I'm trying to understand what I'm looking at. So I get the if statement. But I'm fuzzy on the "ME" statement. Where does ME come from? How do I know when I'm writing code that I have to use ME? I then get the Toggle. That's the action and I get the Then statement. But I'm stuck on the ME again and what control "control" is referencing. But Default Value is the value placed in the field at the time this event is run so I kinda get that. And then I get the Else statement and the to leave the field empty with the "".

    Correct?

  2. #32
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Me is shorthand reference for the form or report the code is behind.

    Control and toggle would be the names of controls. So replace with the actual names of your controls.
    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. #33
    Collins is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    107
    Quote Originally Posted by June7 View Post
    Me is shorthand reference for the form or report the code is behind.

    Control and toggle would be the names of controls. So replace with the actual names of your controls.
    So as long as the code resides in a particular form or report I can refer to it as ME. Is that what you're saying?

    And control is the name of what ever control I'm going to use. Toggle, Button, Radio. Located right after SUB... Right? Like Sub Toggle1_Click()

  4. #34
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Yes, sounds like you get it.

    Suggest you assign more meaningful names, like: tglSetDate
    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.

  5. #35
    Collins is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    107
    Quote Originally Posted by June7 View Post
    Yes, sounds like you get it.

    Suggest you assign more meaningful names, like: tglSetDate
    So it would read like this:

    If Me.tglSetDate Then
    Me.tglSetDate.DefaultValue = Me.tglSetDate
    Else
    Me.tglSetDate.DefaultValue = ""
    End If

  6. #36
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    No, you don't set DefaultValue of toggle.

    You want to set the default of textbox or combobox. Control is reference to that data control. See my example again.
    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.

  7. #37
    Collins is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    107
    Quote Originally Posted by June7 View Post
    No, you don't set DefaultValue of toggle.

    You want to set the default of textbox or combobox. Control is reference to that data control. See my example again.
    Private Sub Toggle18_Click()

    If Me.toggle Then - So this toggle name does not change.
    Me.control.DefaultValue = Me.control
    Else
    Me.control.DefaultValue = "" - but these controls would be Toggle18?

    End If

    End Sub

  8. #38
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Toggle would be Toggle18 or tglSetDate or whatever you name the toggle button.

    Control would be Combo1 or Text1 or cbxDate or tbxDate or whatever you name the data control.
    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.

  9. #39
    Collins is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    107
    Gotcha... Man... I'm starting to think i'm not cut out to be a programmer...

  10. #40
    Collins is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    107
    So this???

    Private Sub tglSetDate_Click()
    If Me.tglSetDate Then
    Me.tbxDate.DefaultValue = Me.tbxDate
    Else
    Me.tbxDate.DefaultValue = ""
    End If
    End Sub

  11. #41
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Yes, that should do it.
    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.

  12. #42
    Collins is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    107
    Quote Originally Posted by June7 View Post
    Yes, that should do it.
    LOL...OMG!!! Finally!!!

    Thanks for your patients June... I appreciate it...

  13. #43
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Oops, I was wrong - Toggle button does have Default Value property. It can be bound to a Yes/No field and serve as a data control. (corrected my earlier posts)

    Command button does not have Default Value property.
    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.

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

Similar Threads

  1. Replies: 7
    Last Post: 06-07-2015, 11:57 PM
  2. set a date field to 1st january of this year
    By sdel_nevo in forum Programming
    Replies: 5
    Last Post: 08-16-2013, 05:20 AM
  3. Replies: 4
    Last Post: 01-09-2013, 11:16 AM
  4. Replies: 10
    Last Post: 04-21-2010, 01:16 PM
  5. Use field value as the year in a date
    By Eveline in forum Queries
    Replies: 1
    Last Post: 03-11-2010, 10:58 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