If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
query result as button label
On Sat, 6 Dec 2008 23:05:00 -0800, IT-1957
wrote: I really wanted to use the command buttons just becouse it looks more profesional, I been working with a form, on which I have created 20 command bottons, Button0,Botton1,Button3 and so on... I have a query with 20 records, with 2 columns on the query, UPC and DESCRIPTION I wanted to name the buttons using record 1 value on the UPC column as the description of Button0...and so on. Thanks to other members of this forum I have this code : Private Sub Form_Load() Dim rs As DAO.Recordset 'Requires reference to DAO 3.6 Dim i As Integer Set rs = CurrentDb.OpenRecordset("myquery", dbOpenSnapshot) i = 0 While Not rs.EOF Me.Controls("Button" & i).Caption = rs!Caption i = i + 1 rs.MoveNext Wend rs.Close Set rs = Nothing End Sub But I got an error on the "Me.Controls("Button" & i).Caption = rs!Caption" This code suppose to look up the value and set the caption of the button but is not working, As noted in the other newsgroup (hint: it's considered impolite to ask the same question separately in multiple groups, it wastes the volunteers' time), is there a field in myquery named Caption? Your code assumes that there is. Instead of rs!Caption use whatever the actual fieldname is: rs!UPC. -- John W. Vinson [MVP] |
#12
|
|||
|
|||
query result as button label
Thank you, it worked.
Thank you again. I'm sorry about that. |
|
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Still Hoping for help with a Query problem | Don Sealer | Using Forms | 15 | November 13th, 2004 06:24 AM |
Here's a shocker | Mike Labosh | General Discussion | 2 | October 26th, 2004 05:04 PM |
Taher | Setting Up & Running Reports | 1 | August 31st, 2004 09:07 PM | |
Display Parameter from Form on Report | sara | Setting Up & Running Reports | 10 | July 19th, 2004 04:54 PM |
Enabling a button based on a query | Fatz | General Discussion | 4 | July 1st, 2004 02:10 PM |