I need the correct syntax (with all the quotation marks) for Me.frmButtons.Form.Button01.caption in the SQL-string.
This one doesn't work:
Private Sub Button01_Click()
Dim strsql As String
strsql = "SELECT * FROM table01 WHERE fldName = ""Me.bForm.Form.Button01.caption""
ORDER BY FldName"
Me.mForm.Form.RecordSource = strsql
Me.mForm.Form.Requery
End Sub
This should work:
Private Sub Button01_Click()
Dim strsql As String
strsql = "SELECT * FROM table01 " & _
"WHERE fldName = '" & Me!bForm.Form!Button01.Caption & "' " & _
"ORDER BY FldName"
Me!mForm.Form.RecordSource = strsql
End Sub
Also, you should give your buttons meaningful names.