D
Dave F
I have an Access mdb file that is linked to a SQL Server database.
I have two problems with combo boxes that link to tables in the SQL Server
database.
1. One combo box has 200 entries. When the form loads, the cbo is not
fully loaded. For eaxmple, the last 100 records are not available in the
cbo until the user scrolls to them. When the user scrolls through the cbo
sorted alphabetically, it appears that all records through "m" are available
but that no records from "o" through "z" exist. If they enter "z" in the
cbo, they are taken to the first "z" record but if they scroll, they must
continue to scroll to the bottom of the list several times to get to "z."
How can I ensure that the cbo is fully loaded when the form loads?
2. The form has "find record" VBA code (see below) to locate a particular
client record based on the user's selection in the cbo box. The "find
record" cbo works fine except for the last two records. If either of those
records are selected, the first record (rather than the selected record) is
loaded into the form.
What could account for such unexpected behavior?
Here is the VBA code behind the cbo "find record" control:
1. Move to selected record:
Private Sub cboClientID_AfterUpdate()
On Error GoTo ErrorHandler
'Find a client
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ClientID] = " & Str(Nz(Me![cboClientID], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number _
& ": Description: " & Err.Description
Resume ErrorHandlerExit:
End Sub
2. Synch cbo with current record
Private Sub Form_Current()
On Error GoTo ErrorHandler
'Make the client in the cbo the current client
If cboClientID.Column(0) <> txtClientID Then
cboClientID.Value = ClientID
End If
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number _
& ": Description: " & Err.Description
Resume ErrorHandlerExit:
End Sub
I have two problems with combo boxes that link to tables in the SQL Server
database.
1. One combo box has 200 entries. When the form loads, the cbo is not
fully loaded. For eaxmple, the last 100 records are not available in the
cbo until the user scrolls to them. When the user scrolls through the cbo
sorted alphabetically, it appears that all records through "m" are available
but that no records from "o" through "z" exist. If they enter "z" in the
cbo, they are taken to the first "z" record but if they scroll, they must
continue to scroll to the bottom of the list several times to get to "z."
How can I ensure that the cbo is fully loaded when the form loads?
2. The form has "find record" VBA code (see below) to locate a particular
client record based on the user's selection in the cbo box. The "find
record" cbo works fine except for the last two records. If either of those
records are selected, the first record (rather than the selected record) is
loaded into the form.
What could account for such unexpected behavior?
Here is the VBA code behind the cbo "find record" control:
1. Move to selected record:
Private Sub cboClientID_AfterUpdate()
On Error GoTo ErrorHandler
'Find a client
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ClientID] = " & Str(Nz(Me![cboClientID], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number _
& ": Description: " & Err.Description
Resume ErrorHandlerExit:
End Sub
2. Synch cbo with current record
Private Sub Form_Current()
On Error GoTo ErrorHandler
'Make the client in the cbo the current client
If cboClientID.Column(0) <> txtClientID Then
cboClientID.Value = ClientID
End If
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number _
& ": Description: " & Err.Description
Resume ErrorHandlerExit:
End Sub