CHANGE text in button on sheet

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

CHANGE text in button on sheet

Post by sal21 »

Do Until RS1.EOF
Debug.Print RS1.Fields(0).Value
RS1.MoveNext
Loop

this code loop a dates fields.

i need to change the text name of each nutton in sheet attached, hot to via vba code?

note:

1)the rs1 loop contain only and always 3 filed dates
2)i need for filds(0).value modify the text name of first button, renamed for filds(1).value modify the text name of second button, ecc
3) The format of dates is MM/YYYY
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CHANGE text in button on sheet

Post by HansV »

Your code loops through the records, but in your instruction #2, you "loop" through the fields of a record. What exactly do you want? How many records does the recordset have, and how many fields?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: CHANGE text in button on sheet

Post by sal21 »

HansV wrote:Your code loops through the records, but in your instruction #2, you "loop" through the fields of a record. What exactly do you want? How many records does the recordset have, and how many fields?
sorry me, only one fileds with three values.

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CHANGE text in button on sheet

Post by HansV »

Code: Select all

    Dim i As Long
    Do Until RS1.EOF
        i = i + 1
        ActiveSheet.Buttons("Button " & i).Caption = RS1.Fields(0).Value
        RS1.MoveNext
    Loop
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: CHANGE text in button on sheet

Post by sal21 »

HansV wrote:

Code: Select all

    Dim i As Long
    Do Until RS1.EOF
        i = i + 1
        ActiveSheet.Buttons("Button " & i).Caption = RS1.Fields(0).Value
        RS1.MoveNext
    Loop
PERFECT! :thankyou: