Bootcamp Homework Help: Option Button Isn't Populating Query (1 Viewer)

austinsneeze

New member
Local time
Today, 11:11
Joined
May 5, 2023
Messages
6
I have a query that is supposed to populate in my unbound list box when the option button is selected.

Screenshot 2023-05-21 175544.png


But it isn't populating

1684709954701.png


The "Type as you go filter" does work with the "Starts with..." option button, but the list box isn't generating the query on click.

ezgif-4-99fdb74cec.gif


Code:
Private Sub Form_Load()

Me.txtFltr_lstMtrls.Enabled = False

End Sub

Private Sub fraSrchTyp_AfterUpdate()
Select Case fraSrchTyp

Case 1
Me.lstMtrls.RowSource = "qrylstMtrls_SrtsWth"
Me.txtFltr_lstMtrls.Enabled = True

Case 2
Me.lstMtrls.RowSource = "qryMtrls_Cntns"
Me.txtFltr_lstMtrls.Enabled = True

Case 3
Me.lstMtrls.RowSource = "qrylstMtrls_All"
Me.txtFltr_lstMtrls.Enabled = False

End Select
End Sub

Private Sub lstMtrls_DblClick(Cancel As Integer)
If Not IsNull(Me.lstMtrls.Value) Then
'Me.Recordset.FindFirst "MtrlNm = '" & Me.lstMtrls & "'"
Form.Requery
End If
End Sub



Private Sub txtFltr_lstMtrls_Change()
If txtFltr_lstMtrls.Text = "" Then
lstMtrls.RowSource = "qrylstMtrls_All"
Else

        If fraSrchTyp = 1 Then
        lstMtrls.RowSource = "qrylstMtrls_StrtsWth"
        Else
        lstMtrls.RowSource = "qryMtrls_Cntns"
       
        End If
End If
End Sub
 

Attachments

  • ezgif-4-99fdb74cec.gif
    ezgif-4-99fdb74cec.gif
    264.8 KB · Views: 63
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 09:11
Joined
Oct 29, 2018
Messages
21,474
Hi. Welcome to AWF!

I am not sure I understand the problem. Do all your queries for the Listbox show any records in them? Where does the "start with" and "contains" information come from?
 

austinsneeze

New member
Local time
Today, 11:11
Joined
May 5, 2023
Messages
6
Hi. Welcome to AWF!

I am not sure I understand the problem. Do all your queries for the Listbox show any records in them? Where does the "start with" and "contains" information come from?
Hi! Under the query criteria comes my "starts with" and "contains" information. I have 3 queries: 1) starts with 2) contains, and 3) all materials. All of my queries correspond with each option button.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:11
Joined
Oct 29, 2018
Messages
21,474
Hi! Under the query criteria comes my "starts with" and "contains" information. I have 3 queries: 1) starts with 2) contains, and 3) all materials. All of my queries correspond with each option button.
In the image you posted, I see the list box get populated when you select an option except for starts with. That's why I asked if all your queries return data. The form seems to work from what I can see.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 17:11
Joined
Feb 19, 2013
Messages
16,614
I train my users to use the * character so users enter

text*

Or
*text*

or just
*
for all records
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:11
Joined
May 21, 2018
Messages
8,529
Code:
Private Sub lstMtrls_DblClick(Cancel As Integer)
If Not IsNull(Me.lstMtrls.Value) Then
'Me.Recordset.FindFirst "MtrlNm = '" & Me.lstMtrls & "'"
Form.Requery
End If
End Sub

It is not failing, but your extraneous requery makes it seem like it does. If you do a find first it moves to the record, then you immediately requery bringing it back to the first record. It appears to do nothing.
Also if MtrlNm is numeric get rid of the parentheses.
 

Users who are viewing this thread

Top Bottom