Need help with automatically added date (1 Viewer)

moke123

AWF VIP
Local time
Today, 18:18
Joined
Jan 11, 2013
Messages
3,920
Just for kix I added a different type of search to your form.
Its a "search as you type" with a listbox. Double click in the listbox to filter your calling form.
 

Attachments

  • Search problem (1).accdb
    1.3 MB · Views: 125

113hans

Member
Local time
Tomorrow, 05:18
Joined
Mar 31, 2021
Messages
47
"Search as you type", never cross my mind, I tried it for purpose of diversifying my option on some day, but when I increased the column count to 4, it still only showed the content of Hoten field, what happened here?

Untitled.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:18
Joined
May 7, 2009
Messages
19,245
you need to Increase to Column Count of the listbox, also you need to add the Column Width.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:18
Joined
May 7, 2009
Messages
19,245
check the list0 rowsource, does it have all the column.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:18
Joined
May 7, 2009
Messages
19,245
no, the Listbox, rowsource.
 

113hans

Member
Local time
Tomorrow, 05:18
Joined
Mar 31, 2021
Messages
47
I think may be the problem is in his code

Private Sub Text2_Change()
'SELECT [Bangchinh].[Maluutru], [Bangchinh].[Hoten] FROM Bangchinh;
Dim strSql As String
strSql = "SELECT [Bangchinh].[Maluutru], [Bangchinh].[Hoten] FROM Bangchinh where Hoten like ""*" & Me.Text2.Text & "*"""
Me.List0.RowSource = strSql
End Sub


Text2 is where I enter the keyword.
I wish to put Tuoi field = Age field, Ngay field = Date visit field, they are all number, don't know how to fill the code o_O
 

moke123

AWF VIP
Local time
Today, 18:18
Joined
Jan 11, 2013
Messages
3,920
According to your notes in the DB you were just searching for a client so thats all I included in the SQL. The rowsource is established in code, not in the listbox.

note the following events

Code:
Private Sub Form_Load()
    Me.List0.RowSource = "SELECT Bangchinh.Maluutru, Bangchinh.Hoten, Bangphu.Yeucau, Bangchinh.Ketluan, Bangchinh.Tuoi, Bangchinh.Ngaysieuam,  " & _
    "Bangchinh.Diachi FROM Bangphu INNER JOIN Bangchinh ON Bangphu.Mayeucausieuam = Bangchinh.Mayeucausieuam WHERE Maluutru = 0"
End Sub
Thats just to load a blank record in listbox because I set column heads to yes.

Code:
Private Sub Text2_Change()

    Dim strSql As String

    strSql = "SELECT Bangchinh.Maluutru, Bangchinh.Hoten, Bangphu.Yeucau, Bangchinh.Ketluan, Bangchinh.Tuoi, Bangchinh.Ngaysieuam,  " & _
             "Bangchinh.Diachi FROM Bangphu INNER JOIN Bangchinh ON Bangphu.Mayeucausieuam = Bangchinh.Mayeucausieuam " & _
             "WHERE   [Maluutru] & [Hoten] & [Ngaysieuam] & [Diachi] & [Tuoi] & [Yeucau]   Like ""*" & Me.Text2.Text & "*"""

    Me.List0.RowSource = strSql

End Sub
This is where the rowsource is set for the listbox


heres copy with changes
 

Attachments

  • Search problem (1).accdb
    1.6 MB · Views: 122
Last edited:

113hans

Member
Local time
Tomorrow, 05:18
Joined
Mar 31, 2021
Messages
47
it uses Conditional Format (Ribbon->Format->Conditional Formatting).
on the search form i modified, open in Design View, select all the textboxes on the Detail
section of the form.
Go to ribbon and see the Conditional Formatting.
The search which I found has a text box with the content like "... results were found." That search uses a list box, I see this code:
= IIf(ListBoxName.ListCount-1=-1,"0",ListBoxName.ListCount-1) & "results were found."
Can you help me with that on your search db?
 

113hans

Member
Local time
Tomorrow, 05:18
Joined
Mar 31, 2021
Messages
47
According to your notes in the DB you were just searching for a client so thats all I included in the SQL. The rowsource is established in code, not in the listbox.

note the following events

Code:
Private Sub Form_Load()
    Me.List0.RowSource = "SELECT Bangchinh.Maluutru, Bangchinh.Hoten, Bangphu.Yeucau, Bangchinh.Ketluan, Bangchinh.Tuoi, Bangchinh.Ngaysieuam,  " & _
    "Bangchinh.Diachi FROM Bangphu INNER JOIN Bangchinh ON Bangphu.Mayeucausieuam = Bangchinh.Mayeucausieuam WHERE Maluutru = 0"
End Sub
Thats just to load a blank record in listbox because I set column heads to yes.

Code:
Private Sub Text2_Change()

    Dim strSql As String

    strSql = "SELECT Bangchinh.Maluutru, Bangchinh.Hoten, Bangphu.Yeucau, Bangchinh.Ketluan, Bangchinh.Tuoi, Bangchinh.Ngaysieuam,  " & _
             "Bangchinh.Diachi FROM Bangphu INNER JOIN Bangchinh ON Bangphu.Mayeucausieuam = Bangchinh.Mayeucausieuam " & _
             "WHERE   [Maluutru] & [Hoten] & [Ngaysieuam] & [Diachi] & [Tuoi] & [Yeucau]   Like ""*" & Me.Text2.Text & "*"""

    Me.List0.RowSource = strSql

End Sub
This is where the rowsource is set for the listbox


heres copy with changes
Which part of the code is "search as you type", can I have it inserted in the search box which @arnelgp modified for me? Or it's just a feature for listbox only?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:18
Joined
Feb 19, 2002
Messages
43,288
You have to set the columns property of the listbox to show more columns
 

Users who are viewing this thread

Top Bottom