Hey everyone! I have a couple years of experience with Java but that was about 6 years ago by now, and this VBA is a bit different.
I have a table with three Record Sets [ID], [caption], and [toRun]. The idea is to have a form change the captions of premade buttons to the contents of [caption] and then open a form or report listed in [toRun]. My current code is:
I have a feeling the whole "buttonName" isn't working properly because it's trying to find a button named "buttonName" instead of the buttonName string... what am I overlooking there?
Apart from that this should work right?
I have a table with three Record Sets [ID], [caption], and [toRun]. The idea is to have a form change the captions of premade buttons to the contents of [caption] and then open a form or report listed in [toRun]. My current code is:
Code:
Private Sub Form_Current()
Dim buttonName As String
Dim i As Integer
i = 0
Do Until i = CurrentDb.TableDefs("MainMenu").RecordCount
buttonName = "button" + i
Me(buttonName).Caption = DLookup("Caption", "MainMenu", "ID=" + i)
Me(buttonName).OnClick = DoCmd.OpenForm(DLookup("toRun", "MainMenu", "ID=" + i))
i = i + 1
Loop
End Sub
Apart from that this should work right?
Last edited: