Excel_Kid1081
Registered User.
- Local time
- Today, 03:17
- Joined
- Jun 24, 2008
- Messages
- 34
Hello-
In a form I have two controls...a unbound combo box and an unbound textbox. I have the following OnChange event for the combo box to populate a value for the textbox. However, it only works when a record is found from the dropdown box...but within this combox box the user should be able to enter in new info if it is not listed. I thought my if statment below would solve for it but it just seems to default to the previous value selected from the combo.
Private Sub cboObligor_Change()
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set Db = CurrentDb
Set rs = Db.OpenRecordset("tblObligors", dbOpenDynaset)
strSQL = "[Obligor] ='" & Me.cboObligor.Column(0) & "'"
With rs
.FindFirst (strSQL)
If .NoMatch Then
txtHiddenObligorID = DLast("[Obligor_ID]", "[tblObligors]") + 1
Else
txtHiddenObligorID = dlookup("[Obligor_ID]", "[tblObligors]", strSQL)
End If
End With
Set rs = Nothing
Set Db = Nothing
End Sub
Any thoughts are greatly appreciated!!
EK
In a form I have two controls...a unbound combo box and an unbound textbox. I have the following OnChange event for the combo box to populate a value for the textbox. However, it only works when a record is found from the dropdown box...but within this combox box the user should be able to enter in new info if it is not listed. I thought my if statment below would solve for it but it just seems to default to the previous value selected from the combo.
Private Sub cboObligor_Change()
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set Db = CurrentDb
Set rs = Db.OpenRecordset("tblObligors", dbOpenDynaset)
strSQL = "[Obligor] ='" & Me.cboObligor.Column(0) & "'"
With rs
.FindFirst (strSQL)
If .NoMatch Then
txtHiddenObligorID = DLast("[Obligor_ID]", "[tblObligors]") + 1
Else
txtHiddenObligorID = dlookup("[Obligor_ID]", "[tblObligors]", strSQL)
End If
End With
Set rs = Nothing
Set Db = Nothing
End Sub
Any thoughts are greatly appreciated!!
EK