Harry Paraskeva
Registered User.
- Local time
- Today, 22:32
- Joined
- Sep 8, 2013
- Messages
- 67
Hello everyone,
A question on combo-boxes this time.
I have a modal and pop-up form that loads and gets filtered when you click a button on another form. The pop-up/modal form contains an unbound lookup combo-box for quick navigation between the records. However, I want to set the row source for the aforementioned combo-box to match the form's filter.
So far, I've produced the following, which does not seem to work. My guess is that VBA doesn't understand the introduction of variables in the strsql string or I've introduced it the wrong way.
Thank you for any help. If I come up with a solution, I'll share.
PS: The filter contents is of this form: RadiocarbonID = 7
This is why I've used -2 +2 for the FieldName and FieldIDValue respectively.
A question on combo-boxes this time.
I have a modal and pop-up form that loads and gets filtered when you click a button on another form. The pop-up/modal form contains an unbound lookup combo-box for quick navigation between the records. However, I want to set the row source for the aforementioned combo-box to match the form's filter.
So far, I've produced the following, which does not seem to work. My guess is that VBA doesn't understand the introduction of variables in the strsql string or I've introduced it the wrong way.
Code:
Dim strsql As String
Dim EqualPosition As Integer
Dim FieldName As String
Dim FieldIDValue As String
If Not IsNull(Me.Filter) Then
EqualPosition = InStr(Me.Filter, "=")
If EqualPosition > 0 Then
FieldName = Left$(Me.Filter, EqualPosition - 2)
FieldIDValue = Mid$(Me.Filter, EqualPosition + 2)
End If
End If
strsql = "SELECT Tbl_PrimaryCitations.ID, Tbl_Bibliography.Citation_Form AS Citation, Tbl_PrimaryCitations.Specific_Citation AS Specifics, Tbl_PrimaryCitations.Comments_Notes AS Notes, Tbl_PrimaryCitations.RadiocarbonID " & vbCrLf & _
"FROM Tbl_Bibliography INNER JOIN Tbl_PrimaryCitations ON Tbl_Bibliography.ID = Tbl_PrimaryCitations.CitationID " & vbCrLf & _
"WHERE ((""Tbl_PrimaryCitations."" & FieldName & ""= &"" & FieldIDValue)) " & vbCrLf & _
"ORDER BY Tbl_Bibliography.Citation_Form, Tbl_PrimaryCitations.Specific_Citation;"
Me.FilterSelector.RowSource = strsql
Thank you for any help. If I come up with a solution, I'll share.
PS: The filter contents is of this form: RadiocarbonID = 7
This is why I've used -2 +2 for the FieldName and FieldIDValue respectively.
Last edited: