How does access solve a problem where a combo box doesn't meet a large number of data choices?

Source: Internet
Author: User
Tags integer access
access| Solution | data | problem
How do I solve a problem where a combo box doesn't meet a large number of data choices?





Problem:

Access has a combo box that allows you to quickly select the data you want from the Multiline records. But what if the record is over 1000-2000? The choice is very inconvenient. What am I going to do?





Reply:


In fact, a lot of data can be sorted (layered) to select, and we can filter the data beforehand.
The following example is the choice of multi-level data by opening the same form class repeatedly.
Of course, the pre-filtered data feature is also included.


Before reading this article, please refer to:
Novice: How to design a table structure for the TreeView display? 》
Http://access911.net/index.asp?board=4&recordid=75FABE1E12DC
Article to learn how to define a data table structure that can be easily categorized and displayed.

and read:
How do I open a form 2 times, and each time the open form displays different data? 》
Http://access911.net/index.asp?board=4&recordid=72FAB11E15DC
Article to learn that a FORM in ACCESS is actually a class

Okay, here we go:
1, create a form (Testform), which has a text box (TEXT0), a button (Command2).
2, create a form (Selectform), which has a list box (LIST0).
3. Write the following code in the "updated" event of the text box in Testform to open the name selection form (selectform) and assign the row source (RowSource) of the list box (LIST0).
Private Sub text0_afterupdate ()
DoCmd.OpenForm "Selectform"
' This line of code implements the fuzzy retrieval of the btype table, using the LIKE keyword in the WHERE clause for the wildcard
Forms ("Selectform"). List0.rowsource = "Select Btype.soncount, Btype. Usercode, Btype. FullName, Btype.typeid from btype WHERE btype.fullname like ' * ' & text0.value & ' * '
End Sub

4. Write the following code in the "click" Event of the command button in Testform to open the name selection form and search by category
5, and then enter the following code in Testform to complete the ability to open the form itself more than once and display the data in the subclass.
To make the code reusable, two common processes are written

Option Compare Database
Dim F


Private Sub form_keydown (keycode As Integer, Shift as Integer)
' Set the key preview property of the form to Yes ' first
' This process will accelerate your input speed
' If you press the ESCAPE key, close the form
If keycode = Vbkeyescape Then
Closeallselectform "Selectform"
End If
End Sub

Private Sub List0_dblclick (Cancel as Integer)
Checkyouselect
End Sub

Private Sub list0_keypress (KeyAscii as Integer)
' This procedure enables full keyboard operation
If KeyAscii = Then
Checkyouselect
End If
End Sub

Sub Closeallselectform (strformname as String)
' General process 1
' This procedure is used to close all forms with the specified name
For each objform in Forms
If objform.name = Strformname Then
DoCmd.Close acform, Objform.name
End If
Next Objform
End Sub

Sub Checkyouselect ()
' General process 2
' Test your choice.
' If found Suncount listed as 0 (indicates no next layer)
' You can put your selected product name into a text box.
On Error Resume Next
Set f = New Form_selectform
Dim Objform as Form
If list0.column (0) = 0 Then
Forms ("Testform"). Text0.value = List0.column (2)
Closeallselectform "Selectform"
Else
F.visible = True
F.list0.rowsource = "Select Btype.soncount, Btype. Usercode, Btype. FullName, Btype.typeid from btype WHERE parid= ' "& List0.value &" "
End If
End Sub



For a detailed sample program, please refer to:
Http://www.access911.net/index.asp?board=8&recordid=77FAB71E







Http://access911.net Webmaster Collection


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.