Command Button Caption DLOOKUP (1 Viewer)

liam9911

New member
Local time
Today, 11:09
Joined
Dec 6, 2014
Messages
5
Hey guys not sure if im on the right section here but i will give it a go

i have a table called EPOS_LAYOUT
ID Short Text PK
BUTTON NAME Short Text
POS Short Text

I have a form with command buttons on going from CMD_1 - CMD_40

I am wanting to open the form and ON OPEN i want the CMD_1 command button to use the value of BUTTON NAME as the caption on the record ID 1

this means that i will end up with the last one CMD_40 with the BUTTON NAME for record ID 40

I have been looking at a way of using DLOOKUP but i have just been given error codes and after hours of looking online and a few days racking my brain i have hit a wall :banghead:

any help will be great

cheers guys
 

Minty

AWF VIP
Local time
Today, 11:09
Joined
Jul 26, 2013
Messages
10,354
You will have to do the following - Open a recordset with you table data in it.
Loop around that dataset and using something like this in the loop
(Aircode untested)

Code:
Dim rs as recordset
Dim iLoop as integer
Dim sCurrButt as String

Set rs = "SELECT * from YourTable Order By ID"
iLoop = 1

While Not rs.EOF 
    sCurrButt = "CMD_" & iLoop
    debug.print sCurrButt
    Me.Controls(sCurrButt).Caption = rs.Fields("Button Name")
    iLoop = iLoop + 1
    rs.MoveNext
Wend
 
Last edited:

Users who are viewing this thread

Top Bottom