Question about Business & Productivity Software

5 Answers

Is it possible to use a variable expression in VBA for a form label?

I want to place 100 different values for 100 different labels on a form. I can do it simply with the following loop, but VBA won't accept any syntax I have tried for the label name.
For CT = 1 to 100
[Forms]![F3-subject index]!["sn"&CT].Caption=valuearray(CT)
next CT
How can this loop be accomlished?

Posted by on

  • 3 more comments 
  • Bushtrekker Sep 12, 2008

    The solution didn't seem to address my problem

  • Bushtrekker Sep 12, 2008

    This solution relates to excel. I am working with labels on an access form. Can my loop be performed in VBA or DAO for access? If so, what is the syntax?

  • Bushtrekker Sep 12, 2008

    I already spent a day searching various forums and links such as the one you suggest. They do not address the particular question: "Can a variable be used in VBA to designate the label name on a form? If so, what is the syntax? IF not, can it be done in DAO? If so, what is the syntax?

  • Bushtrekker Sep 12, 2008

    Coolguy008 suggests:
    Dim lbl as label
    lbl.Caption = "string"
    [Forms]![F3-subject index]![sn5] = label
    But, "sn5" in your solution is not a variable. I want to use a variable in the place of [sn5]. If this is a solution, you'll have to explain it to me.

  • Bushtrekker Sep 12, 2008

    Yes, Suben, that is exactly what I did. But, that syntax doesn't work.

×

5 Answers

  • Level 3:

    An expert who has achieved level 3 by getting 1000 points

    All-Star:

    An expert that got 10 achievements.

    MVP:

    An expert that got 5 achievements.

    Genius:

    An expert who has answered 1,000 questions.

  • Master
  • 1,665 Answers

Have a look at some relative questions

Posted on Sep 12, 2008

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that got 5 achievements.

    Sergeant:

    An expert that has over 500 points.

    Champion:

    An expert who has answered 200 questions.

  • Expert
  • 214 Answers

try this
Dim lbl as label
lbl.Caption = "string"
[Forms]![F3-subject index]![sn5] = label

hope it works

Posted on Sep 12, 2008

  • Subhendu Das
    Subhendu Das Sep 12, 2008

    or this
    [Forms]![F3-subject index]!["sn"&CT].Caption=valuearray(CT)

    next CT



×

  • Level 3:

    An expert who has achieved level 3 by getting 1000 points

    All-Star:

    An expert that got 10 achievements.

    MVP:

    An expert that got 5 achievements.

    President:

    An expert whose answer got voted for 500 times.

  • Master
  • 1,952 Answers



download tis software and use it
Financial Excel All Programs Complete Edition

then check ur loop is correct in syntax

use tis below links for tutorial

http://www.lacher.com/toc/tutvba1.htm

http://www.blueclaw-db.com/access_createquerydef.htm




Posted on Sep 12, 2008

  • Level 3:

    An expert who has achieved level 3 by getting 1000 points

    All-Star:

    An expert that got 10 achievements.

    MVP:

    An expert that got 5 achievements.

    Genius:

    An expert who has answered 1,000 questions.

  • Master
  • 3,422 Answers

HI,

Please click on the below link and go through the post.It will help you fix your problem.

http://www.dailydoseofexcel.com/archives/2006/12/04/writing-to-a-range-using-vba/

Posted on Sep 12, 2008

  • 2 more comments 
  • Priya darshan Sep 12, 2008

    Please don't forget to accept the solution as fixya.

  • Priya darshan Sep 12, 2008

    Please don't forget to accept the solution as fixya.



  • Priya darshan Sep 12, 2008

    ok..please try out this syntax


    Dim lbl as label

    lbl.Caption = "string"

    [Forms]![F3-subject index]![sn5] = label

    I hope this will help and please don't forget to accept my solution.



  • Priya darshan Sep 12, 2008

    Did you already try this:

    Dim lbl as label

    lbl.Caption = "string"

    [Forms]![F3-subject index]![sn5] = label



×

  • Level 3:

    An expert who has achieved level 3 by getting 1000 points

    All-Star:

    An expert that got 10 achievements.

    MVP:

    An expert that got 5 achievements.

    Genius:

    An expert who has answered 1,000 questions.

  • Master
  • 1,239 Answers

    • hi,,
    •  u could find the link.. for label name..
    • www.functionx.com/​vbaccess/​Lesson09.htm
    •  
        thank u sir..

Posted on Sep 12, 2008

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

How do i calculate a difference in a percent?


If the value in A1 is 100, and the value of A2 is 120, then the formula =(A2/A1)-1 will return 0.2. If the cell containing the formula is then formatted to display as percentage it will show as 20%.

Dec 13, 2013 | Microsoft Excel for PC

1 Answer

Excel vba


For complete guide please refer to this link
http://www.fontstuff.com/VBA/vbatut03.htm

Thanks and regards

Fixya is educating to educate

May 12, 2009 | Microsoft Office Professional Edition 2003...

1 Answer

In Excel trying to compare two ranges


I imagine that the only way is with VBA coding. This is possible if you know programming in Excel (VBA - Visual Basic for Applications).

Apr 17, 2009 | Oracle Database Enterprise Named User Plus

2 Answers

Constants/missing correlations in SPSS


If all values for a specific "dummy" variable are identical, then you should delete the variable, because it adds NO information to your analysis.

If all values for one "dummy" variable MATCH the values for another "dummy" variable, then the two variables are 100% correlated -- remove one of them from your analysis.

Apr 06, 2009 | SPSS 13.0 (30960UU)

1 Answer

Macro


Hi alwinkumar

You can set a default value in most form items under the properties of that item. Look for "value". You can also do this in code, by setting up a sub routine to set/reset the values on your form. Then just run the sub routine before you open or enter the form.

Private Sub resetForm()

'formname.itemname = value
UserForm1.Label1 = "Hello World"

End Sub

For the second one you have a couple of options, you can find the bottom on the data and store the row index in a variable, use a loop to find the next empty cell in a row, and store the value or you can use the current region method to select all the cells with data continously touching the selected range. Example below

numberOfRows = Sheet1.Range("A1").CurrentRegion.Rows.Count

Jul 16, 2008 | Microsoft Office Professional 2007 Full...

1 Answer

Sumproduct or conditional sumif with multiple criteria in vba code...


i'll just reply to your conditional sumif query.

yes, you can do multiple criteria query but with a matrix formula. you may look it up. nonetheless, here is how one would look like:

{=sum(if(range1=A x range2=B x range3=C, sum range))} note that x (multiplication) is used to denote intersection of the criteria

initially, you'll enter it as:
=sum(if(range1=A x range2=B x range3=C, sum range))

then, edit the cell (F2) and press ctrl+shift+enter for the brackets { } to appear.

Jun 27, 2008 | Microsoft Excel for PC

1 Answer

How to compare a value in a subform with parent form's value in Dcount


Assuming that Process id is an integer, this should do the trick:

DCount("[stageid]", "Process Stages", "[Process id] = " & Me.Parent! [Process id])

Regards -- Joe (Access VBA samples)

May 01, 2008 | Microsoft Office Access 2003 (077-02871)...

1 Answer

Problem with macro and On Open procedure


Ignore the warning (it's there for your protection). Do a search for your default page and / or insert it into your expression, presumably a script of some sort from (who knows where and being a bit more specific would have helped....grrr). The last problem might be because you have them located in a different area (folder). Check and see. Search (or find) on the name of one that does show and one that does not appear.

Jan 19, 2008 | Microsoft Office Access 2003 (077-02871)...

1 Answer

Labeling from exel


If you follow the Mail Merge instructions built into Microsoft Word's Mail Merge Wizard, you can use your Excel file as the data source for your Mail Merge document, which can be created using label templates built into Word or downloaded from the label manufacturer's website. If you need more detailed instructions, please let us know what version of Microsoft Office you're using, as well as the Operating System (PC or Mac, Windows '98, XP, Vista, Leopard, etc.) and the label manufacturer and label name and product number. Please let us know if you need more help.

Dec 11, 2007 | Business & Productivity Software

2 Answers

Office-2003


What Kind of Operating System you use? If you're using Windows XP, it's easy just click a print Icon and choose a Business Card Option for Print Style.

Aug 24, 2007 | Microsoft Office Standard for PC

Not finding what you are looking for?
Business & Productivity Software Logo

Related Topics:

372 people viewed this question

Ask a Question

Usually answered in minutes!

Top Business & Productivity Software Experts

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

Les Dickinson
Les Dickinson

Level 3 Expert

18297 Answers

Sudeep Chatterjee
Sudeep Chatterjee

Level 3 Expert

3267 Answers

Are you a Business and Productivity Software Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...