KeithIT
Registered User.
- Local time
- Today, 01:51
- Joined
- Dec 20, 2004
- Messages
- 133
I have a combo box on my bound form which has a control source in the query and a row source of another query. The combo box has the following code associated with it's BeforeUpdate property:
My problem is that (aside from any problems I may have in the code above) when I open the form and try to select an item in the list using the mouse, the combo box doesn't change the entry, until I select it a second time. When I select it the first time apparently it updates the record in the table, but not the combo box. It's quite strange. When I type the entry into the combo box and then select from the list that comes up after you type in the first few letters, it works fine everytime.
I don't know if the problem is in my code, my placement of the code (i.e.: in the BeforeUpdate property) or elsewhere, but any help or direction would be most appreciated. Thanks in advance!
Keith
Code:
Private Sub cboSiteName_BeforeUpdate(Cancel As Integer)
Dim rs As Object
Dim rst As New ADODB.Recordset
Dim nRecords As Integer
Dim site As String
site = Me.cboSiteName.Column(0)
Select Case MsgBox("Do you want to search for this record?", vbQuestion + vbYesNoCancel, "Search or Update")
Case vbYes
nRecords = DCount("*", "qrySiteListing")
If nRecords > 1 Then
DoCmd.OpenForm "frmSiteSelect", acNormal, , , , acWindowNormal
Me.cboSiteName.Undo
DoCmd.RunCommand acCmdSaveRecord
Exit Sub
Else
Set rs = Me.RecordsetClone
rs.FindFirst "[lngzSiteID] =" & site
Me.cboSiteName.Undo
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
DoCmd.RunCommand acCmdSaveRecord
End If
Case vbNo
If MsgBox("Confirm you would like to update the information for this entry", vbExclamation + vbOKCancel, "Confirm!") = vbOK Then
Exit Sub
Else
End If
Cancel = True
Case vbCancel
Cancel = True
End Select
End Sub
My problem is that (aside from any problems I may have in the code above) when I open the form and try to select an item in the list using the mouse, the combo box doesn't change the entry, until I select it a second time. When I select it the first time apparently it updates the record in the table, but not the combo box. It's quite strange. When I type the entry into the combo box and then select from the list that comes up after you type in the first few letters, it works fine everytime.
I don't know if the problem is in my code, my placement of the code (i.e.: in the BeforeUpdate property) or elsewhere, but any help or direction would be most appreciated. Thanks in advance!
Keith