Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find out the contents of a variable

Status
Not open for further replies.

Kozia

Programmer
Sep 9, 2002
18
0
0
CA
I have a form with 30 buttons on it named cmd1, cmd2 and so on. They all have different Caption which is cost ID.
along with buttons I have display fields that holds the description of the corresponding button. However the description is captured from a table onLoad.

to get the description and display it I have:
tmpText = cmd1.Caption
Set rstSet = dbs.OpenRecordset("SELECT [Cost Id].Description FROM [Cost Id]WHERE ([Cost Id].CostID)='" & tmpText & "';")
rstSet.MoveFirst
Me![text1] = rstSet![Description]

for cmd2 is same as above with cmd2 substituted for cmd1 and so on.

I want to do all buttons in a while statement The problem is how do I get the contents of the variable
i=1
While i < 32
tmpCmd = Val(&quot;cmd&quot; & i & &quot;.Caption&quot;)????This returns cmd1.Caption not the caption on a button.



 
Try

controlName = &quot;cmd&quot;&i

Me.Controls(controlName).Caption

Could work.

Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top