Results 1 to 8 of 8
  1. #1
    mkfloque is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    24

    code not working/ syntax?

    Hello All,

    I'm brand-new to code, and can't get this to work; i have double-checked field names, etc. Am i using incorrect syntax? thanks!


    Private Sub Form_Current()


    If Me.PaymentMethod = "CreditCard" Then
    Me.CredCardNo.Enabled = True
    Else
    Me.CredCardNo.Enabled = False
    End If
    End Sub

    Private Sub PaymentMethod_AfterUpdate()
    If Me.PaymentMethod = "CreditCard" Then
    Me.CredCardNo.Enabled = True
    Else
    Me.CredCardNo.Enabled = False
    End If
    End Sub

  2. #2
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    "and can't get this to work"

    Nothing is jumping out at me with the syntax, what part is not working?

  3. #3
    mkfloque is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    24
    Quote Originally Posted by redbull View Post
    "and can't get this to work"

    Nothing is jumping out at me with the syntax, what part is not working?

    When i go back to the form, the "CreditCardNo" field is disabled even if "CreditCard" is the PaymentMethod.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Syntax looks fine to me! Does any VBA code run? To allow b]Code[/b] to run in 2007/2010 you need to declare the Folder as 'Trusted.'

    To trust your folder, click:

    1. Office Button (top left)
    2. Access Options (bottom of dialog)
    3. Trust Center (left)
    4. Trust Center Settings (button) on far right
    5. Trusted Locations (left)
    6. Add new location (button)
    7. Enter Folder Name
    8. Click on Okay

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

    All posts/responses based on Access 2003/2007

  5. #5
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Are the control names correct. In your first thread you refer to control CredCardNo and in thread #3 you refer to CreditCardNo. These are different. Is this just a typo in your thread or does it exist in your db.

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

    ...i have double-checked field names
    It must be true, it's on the Internet!

    You can't put anything on the Internet that's not true!
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Quote Originally Posted by Missinglinq View Post
    It must be true, it's on the Internet!

    You can't put anything on the Internet that's not true!

    One of my favorite commercials. Bonjour!

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Yeah! I should of been a French model, too!
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Date Syntax not working
    By Huddle in forum Access
    Replies: 4
    Last Post: 06-27-2012, 11:28 AM
  2. Code Not Working
    By Kirsti in forum Programming
    Replies: 3
    Last Post: 03-26-2012, 02:48 PM
  3. VBA Code to report syntax errors via email
    By jazzkenney in forum Programming
    Replies: 6
    Last Post: 11-30-2011, 08:54 PM
  4. Simple code syntax question
    By mseeker22 in forum Programming
    Replies: 1
    Last Post: 07-07-2011, 03:55 AM
  5. Replies: 3
    Last Post: 10-15-2010, 11:17 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