Combobox hangs due to it having to Validate entry against 500 000 records, can it preload? Need the Combobox as I am using an autofill as you type

I am still new at access and been struggling for two days. Please see below the code that I have used. It is a bit long winded, and I am not sure if that is causing my problem and that is what takes long to run through, sometimes the Combobox hangs for 2-3 Seconds, as it runs through the code as well as the ListParts Query. What I want to know is, is there a way to get the combobox to preload the query so that when I start to input the number it doesn’t hang? Please note I found some of the code like this but have been adding to it to try and improve the program.

Here is the code for a PartType Combobox that is the first field in the record. Once this is selected also from a drop down then

Private Sub PartType_AfterUpdate()
If Me!PartType.Value = "PARTS" Then
Me!PartNumber.RowSource = "ListPART"
Me!UnitPrice.Locked = True
ElseIf Me!PartType.Value = "LABOUR" Then
Me!PartNumber.RowSource = "ListLABOUR"
Me!UnitPrice.Locked = True
ElseIf Me!PartType.Value = "SUNDRIES" Then
Me!PartNumber.RowSource = "ListSUNDRIES"
Me!UnitPrice.Locked = False
ElseIf Me!PartType.Value = "SUBLET" Then
Me!PartNumber.RowSource = "ListBLANK"
Me!UnitPrice.Locked = False
End If

End Sub

I have also used this code in the Forms Change() Sub

Private Sub Partnumber_Change()
'filter dropbox as you type
    'If Len(PartNumber.Text) > 6 Then
    'Dim rs As Recordset
    'Set rs = CurrentDb.OpenRecordset(RecordSQL & " WHERE Code = '" & PartNumber.Text & "' ORDER BY [Code]")
     
    'If (rs.BOF And rs.EOF) Then 'only requery on no exact match
     '   PartNumber.RowSource = RecordSQL & " WHERE Code Like '*' & PartNumber.text & '*' ORDER BY [Code]"
      '  PartNumber.Dropdown
    'End If
    'End If
End Sub

The added kicker is that I have the following code running as I need to check and see if the part has been superceded. How it works is that it opens another form that populates with the data and then sees if there is an “S” is the supercede Textbox. There can sometimes be that a part has had three or four supercession. Please dont judge me on coding.. found this like this.. Any help would be greatly appreciated.

Private Sub PartNumber_AfterUpdate()

If Me!PartType.Value = "PARTS" Then
'FilterComboAsYouType Me.PartNumber, "SELECT * FROM ListParts", "Code"
'PartNumber.LimitToList = False
DoCmd.GoToRecord , , acNext
DoCmd.GoToRecord , , acPrevious
'DoCmd.Requery "ListParts"
'PartNumber.LimitToList = True
'DoCmd.GoToRecord , , acNext
'DoCmd.GoToRecord , , acPrevious
DoCmd.Close acForm, "PartPricesSUB"
DoCmd.OpenForm "PartPricesSUB"
Forms!PartPricesSUB.Visible = False
'supercede 1
    If Forms!PartPricesSUB!Supercede.Value = "S" Then
    Me!PartNumber.Value = Forms!PartPricesSUB!SupercedeCode.Value
    DoCmd.GoToRecord , , acNext
    DoCmd.GoToRecord , , acPrevious
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "UpdateSupercede1"
    DoCmd.SetWarnings True
    DoCmd.GoToRecord , , acNext
    DoCmd.GoToRecord , , acPrevious
    Forms!PartPricesSUB.Visible = False
    DoCmd.Close acForm, "PartPricesSUB"
    DoCmd.OpenForm "PartPricesSUB"
    Forms!PartPricesSUB.Visible = False
    MsgBox "This part number is a supercession here is the new code", vbOKOnly
    Me!TotalPrice.Value = (Me!Qty.Value * Me!UnitPrice.Value) - ((Me!Qty.Value * Me!UnitPrice.Value) * Me![Discount])
        'supercede 2
    If Forms!PartPricesSUB!Supercede.Value = "S" Then
    Me!PartNumber.Value = Forms!PartPricesSUB!SupercedeCode.Value
    DoCmd.GoToRecord , , acNext
    DoCmd.GoToRecord , , acPrevious
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "UpdateSupercede1"
    DoCmd.SetWarnings True
    DoCmd.GoToRecord , , acNext
    DoCmd.GoToRecord , , acPrevious
    Forms!PartPricesSUB.Visible = False
    DoCmd.Close acForm, "PartPricesSUB"
    DoCmd.OpenForm "PartPricesSUB"
    Forms!PartPricesSUB.Visible = False
    MsgBox "This part number is a supercession here is the new code", vbOKOnly
    Me!TotalPrice.Value = (Me!Qty.Value * Me!UnitPrice.Value) - ((Me!Qty.Value * Me!UnitPrice.Value) * Me![Discount])
    End If
        
    'supercede 3
    If Forms!PartPricesSUB!Supercede.Value = "S" Then
    Me!PartNumber.Value = Forms!PartPricesSUB!SupercedeCode.Value
    DoCmd.GoToRecord , , acNext
    DoCmd.GoToRecord , , acPrevious
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "UpdateSupercede1"
    DoCmd.SetWarnings True
    DoCmd.GoToRecord , , acNext
    DoCmd.GoToRecord , , acPrevious
    Forms!PartPricesSUB.Visible = False
    DoCmd.Close acForm, "PartPricesSUB"
    DoCmd.OpenForm "PartPricesSUB"
    Forms!PartPricesSUB.Visible = False
    MsgBox "This part number is a supercession here is the new code", vbOKOnly
    Me!TotalPrice.Value = (Me!Qty.Value * Me!UnitPrice.Value) - ((Me!Qty.Value * Me!UnitPrice.Value) * Me![Discount])
    End If
        
    'Supercede 4
    If Forms!PartPricesSUB!Supercede.Value = "S" Then
    Me!PartNumber.Value = Forms!PartPricesSUB!SupercedeCode.Value
    DoCmd.GoToRecord , , acNext
    DoCmd.GoToRecord , , acPrevious
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "UpdateSupercede1"
    DoCmd.SetWarnings True
    DoCmd.GoToRecord , , acNext
    DoCmd.GoToRecord , , acPrevious
    Forms!PartPricesSUB.Visible = False
    DoCmd.Close acForm, "PartPricesSUB"
    DoCmd.OpenForm "PartPricesSUB"
    Forms!PartPricesSUB.Visible = False
    MsgBox "This part number is a supercession here is the new code", vbOKOnly
    Me!TotalPrice.Value = (Me!Qty.Value * Me!UnitPrice.Value) - ((Me!Qty.Value * Me!UnitPrice.Value) * Me![Discount])
    End If
            
    'Supercede 5
    If Forms!PartPricesSUB!Supercede.Value = "S" Then
    Me!PartNumber.Value = Forms!PartPricesSUB!SupercedeCode.Value
    DoCmd.GoToRecord , , acNext
    DoCmd.GoToRecord , , acPrevious
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "UpdateSupercede1"
    DoCmd.SetWarnings True
    DoCmd.GoToRecord , , acNext
    DoCmd.GoToRecord , , acPrevious
    Forms!PartPricesSUB.Visible = False
    DoCmd.Close acForm, "PartPricesSUB"
    DoCmd.OpenForm "PartPricesSUB"
    Forms!PartPricesSUB.Visible = False
    MsgBox "This part number is a supercession here is the new code", vbOKOnly
    Me!TotalPrice.Value = (Me!Qty.Value * Me!UnitPrice.Value) - ((Me!Qty.Value * Me!UnitPrice.Value) * Me![Discount])
    End If
            
 Else
    DoCmd.GoToRecord , , acNext
    DoCmd.GoToRecord , , acPrevious
    DoCmd.Close acForm, "PartPricesSUB"
    DoCmd.OpenForm "PartPricesSUB"
    Forms!PartPricesSUB.Visible = False
    Me!Description.Value = Forms!PartPricesSUB!Description.Value
    Me!UnitPrice.Value = Forms!PartPricesSUB!UnitPrice.Value
    Me!DscCode.Value = Forms!PartPricesSUB!DscCode.Value
    Me!Qty.Value = "1"
    DoCmd.GoToControl "Qty"
    Me!TotalPrice.Value = (Me!Qty.Value * Me!UnitPrice.Value) - ((Me!Qty.Value *           Me!UnitPrice.Value) * Me![Discount])
    End If

ElseIf Me!PartType.Value = "LABOUR" Then
DoCmd.GoToRecord , , acNext
DoCmd.GoToRecord , , acPrevious
DoCmd.Close acForm, "PartPricesSUB"
DoCmd.OpenForm "PartPricesSUB"
Forms!PartPricesSUB.Visible = False
Me!Description.Value = Forms!PartPricesSUB!Description.Value
Me!UnitPrice.Value = Forms!PartPricesSUB!UnitPrice.Value
Me!DscCode.Value = Forms!PartPricesSUB!DscCode.Value
Me!Qty.Value = "1"
DoCmd.GoToControl "Qty"
Me!TotalPrice.Value = (Me!Qty.Value * Me!UnitPrice.Value) - ((Me!Qty.Value * Me!UnitPrice.Value) * Me![Discount])
        
    
ElseIf Me!PartType.Value = "SUNDRIES" Then
DoCmd.GoToRecord , , acNext
DoCmd.GoToRecord , , acPrevious
DoCmd.Close acForm, "PartPricesSUB"
DoCmd.OpenForm "PartPricesSUB"
Forms!PartPricesSUB.Visible = False
Me!Description.Value = Forms!PartPricesSUB!Description.Value
Me!UnitPrice.Value = Forms!PartPricesSUB!UnitPrice.Value
Me!DscCode.Value = Forms!PartPricesSUB!DscCode.Value
Me!Qty.Value = "1"
DoCmd.GoToControl "Qty"
Me!TotalPrice.Value = (Me!Qty.Value * Me!UnitPrice.Value) - ((Me!Qty.Value * Me!UnitPrice.Value) * Me![Discount])

    
ElseIf Me!PartType.Value = "SUBLET" Then
DoCmd.GoToRecord , , acNext
DoCmd.GoToRecord , , acPrevious
DoCmd.Close acForm, "PartPricesSUB"
DoCmd.OpenForm "PartPricesSUB"
Forms!PartPricesSUB.Visible = False
Me!Description.Value = Forms!PartPricesSUB!Description.Value
Me!UnitPrice.Value = Forms!PartPricesSUB!UnitPrice.Value
Me!DscCode.Value = Forms!PartPricesSUB!DscCode.Value
Me!Qty.Value = "1"
DoCmd.GoToControl "Description"
Me!TotalPrice.Value = (Me!Qty.Value * Me!UnitPrice.Value) - ((Me!Qty.Value * Me!UnitPrice.Value) * Me![Discount])

Else

End If
DoCmd.GoToControl "Qty"
'PartNumber.RowSource = RecordSQL
End Sub


New contributor

Lemmy Dolezal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật