S
Stephen
I have a form that has about 30 buttons (setup as a restaurant menu to
select menu items). The challenge I am having is that the caption on each
button is different depending upon the master field. The challenge I am
having is rather simple though.
I have successfully setup a function that updates the caption on each button
with the appropriate caption. However the coding is rather long because it
has to specifically address EACH button. Hence I get over 30 lines of
repetitive code, with the only difference between lines being the control
name.
I am trying to create a more efficient loop that loops through the buttons,
but I can't get the syntax correct. Below is the code I am writing. Please
help (I have abbreviated some of the code to make it simplier for you to see
what I am doing)....
Function SetItemSelectionModifiers(GenItemID As Integer)
Dim db As DAO.Database
Dim strSQL As String
Dim strSelectItems As String
Dim rs As DAO.Recordset
Dim counter As Integer
Dim strPlaceString As String
Set db = CurrentDb
strSelectItems = "SELECT tblGenericItems.GenItemDescription " & _
"FROM tblGenericItems " & _
"ORDER BY tblGenericItems.GenItemDescription"
Set rs = db.OpenRecordset(strSelectItems)
counter = 0
While Not rs.EOF
counter = counter + 1
'------Set the strPlaceString as the control that is to be updated
strPlaceString = "Forms!frmModifierPopUp.SpecificModifierSelection." &
counter & ".Caption = rs!GenItemDescription"
'------- run the strPlaceString to update the control caption
strPlaceString
rs.MoveNext
Wend
End Function
I was unable to use "strPlaceString" on its own line even though it is a
correct syntax command. What would be the proper syntax to run
"strPlaceString"?
I tried:
docmd.runcommand....
Help...?
select menu items). The challenge I am having is that the caption on each
button is different depending upon the master field. The challenge I am
having is rather simple though.
I have successfully setup a function that updates the caption on each button
with the appropriate caption. However the coding is rather long because it
has to specifically address EACH button. Hence I get over 30 lines of
repetitive code, with the only difference between lines being the control
name.
I am trying to create a more efficient loop that loops through the buttons,
but I can't get the syntax correct. Below is the code I am writing. Please
help (I have abbreviated some of the code to make it simplier for you to see
what I am doing)....
Function SetItemSelectionModifiers(GenItemID As Integer)
Dim db As DAO.Database
Dim strSQL As String
Dim strSelectItems As String
Dim rs As DAO.Recordset
Dim counter As Integer
Dim strPlaceString As String
Set db = CurrentDb
strSelectItems = "SELECT tblGenericItems.GenItemDescription " & _
"FROM tblGenericItems " & _
"ORDER BY tblGenericItems.GenItemDescription"
Set rs = db.OpenRecordset(strSelectItems)
counter = 0
While Not rs.EOF
counter = counter + 1
'------Set the strPlaceString as the control that is to be updated
strPlaceString = "Forms!frmModifierPopUp.SpecificModifierSelection." &
counter & ".Caption = rs!GenItemDescription"
'------- run the strPlaceString to update the control caption
strPlaceString
rs.MoveNext
Wend
End Function
I was unable to use "strPlaceString" on its own line even though it is a
correct syntax command. What would be the proper syntax to run
"strPlaceString"?
I tried:
docmd.runcommand....
Help...?