A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

query result as button label



 
 
Thread Tools Display Modes
  #11  
Old December 7th, 2008, 11:44 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default 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  
Old December 8th, 2008, 02:24 AM posted to microsoft.public.access.forms
IT-1957
external usenet poster
 
Posts: 23
Default query result as button label

Thank you, it worked.
Thank you again.
I'm sorry about that.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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
Print 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


All times are GMT +1. The time now is 01:39 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.