Well I just found out that access 97 has a limit of 64000 records or so in the combo box control. I have a table of customers that I needed to have a combo box that workers could start typing in the name of the company and it would show up in the box. The table has over 600000 records. Time to come up with a different way of doing it.
I made a form with a subform running a query of the large table. In the company field criteria I put Like [Forms]![Form1]![Text4] & "*" where text4 is a control on the main form. the code behind the main form is
Option Compare Database
Dim temphold As Variant
Option Explicit
Private Sub Text4_Change()
Dim i As Variant
DoCmd.RunCommand acCmdRefresh
If ([Forms]![Form1]![Text4] <> temphold Or IsNull(Me!Text4) Or IsNull(temphold)) Then
For i = 1 To 10000
Next i
SendKeys "{f2}"
Else
Me!Text4 = temphold & " "
SendKeys "{f2}"
End If
temphold = [Forms]![Form1]![Text4]
End Sub
So as they start typing in the company name each character they type narrows down the query. The hardest part was if someone typed in a space. I needed to code extra to make that work. I don't like using the sendkeys command but it was the only way I could think of to make the cursor in the text box return to the end of what was typed. The for next loop was needed because if the f2 was sent too fast the query would not filter the new data. Its a little clunky still but the filtering is very fast for 600000 records.
Kind of messy I know - anyone have any other way of doing this?
thanks
sam
I made a form with a subform running a query of the large table. In the company field criteria I put Like [Forms]![Form1]![Text4] & "*" where text4 is a control on the main form. the code behind the main form is
Option Compare Database
Dim temphold As Variant
Option Explicit
Private Sub Text4_Change()
Dim i As Variant
DoCmd.RunCommand acCmdRefresh
If ([Forms]![Form1]![Text4] <> temphold Or IsNull(Me!Text4) Or IsNull(temphold)) Then
For i = 1 To 10000
Next i
SendKeys "{f2}"
Else
Me!Text4 = temphold & " "
SendKeys "{f2}"
End If
temphold = [Forms]![Form1]![Text4]
End Sub
So as they start typing in the company name each character they type narrows down the query. The hardest part was if someone typed in a space. I needed to code extra to make that work. I don't like using the sendkeys command but it was the only way I could think of to make the cursor in the text box return to the end of what was typed. The for next loop was needed because if the f2 was sent too fast the query would not filter the new data. Its a little clunky still but the filtering is very fast for 600000 records.
Kind of messy I know - anyone have any other way of doing this?
thanks
sam