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,