Results 1 to 4 of 4
  1. #1
    Insyderznf is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2009
    Posts
    16

    Strange question, Can you run through the titles in listbox?

    So here is what i have. I have a section of list boxes labeled txtcard0 through txtcard19. Instead of having to do the same line over and over to assign a new variable to each listbox, is there a way to increment the number at the end? I've tried using & and assigning a counter variable and incrementing but neither works. Heres what I have:

    db1.Form_PriceForm.txtCard0.value = "test"
    db1.Form_PriceForm.txtCard1.value = "test"
    db1.Form_PriceForm.txtCard2.value = "test"
    db1.Form_PriceForm.txtCard3.value = "test"
    db1.Form_PriceForm.txtCard4.value = "test"
    db1.Form_PriceForm.txtCard5.value = "test"
    ..............................

    Is there a way to do something like
    Dim Counter
    Counter = 0

    db1.Form_PriceForm.txtCard & Counter.value = "test"

    Counter +1

    ?? If its not possible then no big deal.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You can use the FORMs Controls collection:
    Me.Controls("txtCard" & YourVariable)

  3. #3
    Insyderznf is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2009
    Posts
    16
    Worked like a charm! Well after Access took a dive. I'm not sure what happened but every time i tried to do any type of command access was either saying "out of memory" or "unable to access activeX or OLE control". I had to delete a form and remake it but this works wonderful now! Thank you!

    I wonder if it would be helpful to post my code? It simply takes information from a multiselect box, opens a new form and populates that information into multiple single text boxes on the new form. Next it is going to write to a file.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You can post it if you want us to look at it and offer suggestions.

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

Similar Threads

  1. Replies: 1
    Last Post: 04-09-2009, 09:18 AM
  2. Strange issue with Access 2002 - Any suggestions?
    By mlopezkimco in forum Access
    Replies: 0
    Last Post: 07-30-2008, 09:25 AM
  3. Multi-select listbox and update flag in table
    By Suresh in forum Programming
    Replies: 0
    Last Post: 12-19-2007, 01:04 AM
  4. adding list to a listbox
    By jetrow in forum Access
    Replies: 0
    Last Post: 08-15-2006, 03:36 AM
  5. Replies: 0
    Last Post: 07-24-2006, 06:31 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