Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 12th, 2008, 08:10 AM
Registered User
 
Join Date: Sep 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Populate command btn Captions

I'm building a form that has 16 command buttons with different part numbers on them. I'm currently loading all the part numbers through the code, but I want them to be linked through a table. Is there a way to automatically populate the caption of the command buttons from a table?
 
Old September 12th, 2008, 09:01 AM
Registered User
 
Join Date: Sep 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm currently setting the value of the caption with the following code:

Form_Form1.cmdParts13.Caption = "892"

Instead of "892", I would like to reference a certain location in a table and use that value
 
Old September 17th, 2008, 03:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

What you can do is create a table that has a record number (autonumber), a button number (e.g. 1, 2, etc.), and a part number (e.g. 892).

On the form, number each button sequentially, e.g. cmdButton1, cmdButton2, etc.

On the form's ON OPEN event, you could do

Dim i as Byte

For i = 1 to 15
    Me("cmdButton" & i).Caption = "Part No. " & DLookUp("[PartNo]", "NameOfTable", "[ButtonNo] = " & i)
Next i

But I have to ask why you have 15 buttons. Why not a combobox with the names of the parts listed with ONE button next to it? The user picks a part number from the combobox and then clicks the one button to get to that part.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Radio btn with one Submit btn, convert to 2 Btn ismailc XSLT 2 August 15th, 2008 07:00 AM
ambigious default2 and btn event does not fire shoakat ASP.NET 2.0 Professional 1 June 19th, 2007 10:21 PM
DAP->PivotTable-change FieldList captions harmony82 Access 0 July 14th, 2005 02:03 PM
Executing main() from a control btn aaadetos Visual C++ 3 November 19th, 2004 06:23 PM
Ghost Form Captions MrDannyP Beginning VB 6 0 January 1st, 2004 06:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.