Results 1 to 10 of 10
  1. #1
    Join Date
    May 2004
    Posts
    15

    Unanswered: Create Command Button that works based on criteria

    I have a form that lists the number people signed up for tryouts.

    I only want to be able to add 15 people to that list

    So how do i create an "add record button" that is enabled when the list <=15 and disabled after that.

    thanks

  2. #2
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    How is the list stored? In a list box?

    You will probably need to put the code to enable or disable in a couple of places... One would be an AfterUpdate event. You would have to count the amount of people in the list. Then if count <=15 then cmdwhatever.enabled = true else cmdwhatever.enabled = false.

    I hope you understand where I am coming from,
    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    You could place a check in the OnClick event that will test for the current recordcount of whatever set your populating. If that count is 14, meaning you are making the 15th entry, you could set .enabled = false

    There's actually quite a few places you could put that code... depends on exactly what you're doing here.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  4. #4
    Join Date
    May 2004
    Posts
    15
    When I say "list", i just mean all my records. I have a form that shows my records as "Tabular" layout.

    Im new at access so when Teddy says place a "check" do i have to write some actual VB code?

    I dont know any VB code, sorry for makin it difficult

    I was thinking an IIF statment but i really dont know how to create one
    Last edited by x7tristan; 05-12-04 at 20:39.

  5. #5
    Join Date
    May 2004
    Posts
    15
    any help? really looking for vb code for the onclick event. Also, how do i set a variable to equal the number of records in my form. I am not sure if RecordCount is used for that and if so how to use it.

    I have a textbox(text4) with a label(label5), the textbox's control source is =Count([name]) and this gives me the total number of records on the form. How can i use that number in VB for my command button?
    Last edited by x7tristan; 05-13-04 at 10:06.

  6. #6
    Join Date
    Jul 2003
    Posts
    73
    Code:
    If CInt(text4.value) >= 15 Then
      buttonName.Enabled = False
    Else
      buttonName.Enabled = True
    End If
    This may help.

  7. #7
    Join Date
    May 2004
    Posts
    15
    Im gettin an "object required" error?

  8. #8
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Do you know any VB?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  9. #9
    Join Date
    May 2004
    Posts
    15
    nope none at alll, but yea im an idiot, i just need to put my button name

  10. #10
    Join Date
    Jul 2003
    Posts
    73
    I was going to specifically write that at the bottom Tristan - but forgot about it, sorry.

    At least it worked for you in the end.
    Joel Dixon
    Analyst Programmer
    Melbourne, Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •