nubianqueen
Technical User
I have a piece of code(I didn't write)that I think may work in a combo box I have on a form. Users would select a policy title from the combo box that they want to enter information associataed with title. That information is in a subform. I'm not that good w/VBA. If someone could briefly tell me what this code will do I will greatly appreciate it.
Private Sub cmbPolicyTitle_AfterUpdate()
Dim db As Database, rs As Recordset
Dim tSQL As String, tmp As Boolean
Set db = CurrentDb
Set rst = db.OpenRecordset("qryApproveHead"
If IsNull(Me![cmbPolicyTitle].Text) Then
txtPolicyNum = " "
rst.Close
Else
'find the record that matches the control.
rst.FindFirst "[PolicyTitle] = '" & PolicyTitle "'"
txtPolicyNum = rst!PolicyNum
'find the record that matches the control.
Me.RecordsetClone.FindFirst "[PolicyNum] = " & txtPolicyNum
Me.Bookmark = Me.RecordsetClone.Bookmark
tmp = Me.RecordsetClone.NoMatch
rst.Close
End If
If tmp Then
DoCmd.GoToRecord , , acNewRec
End If
cmbPolicyTitle.SetFocus
End Sub
If more info is needed please let me know. Thanks in advance.
nubianqueen
Private Sub cmbPolicyTitle_AfterUpdate()
Dim db As Database, rs As Recordset
Dim tSQL As String, tmp As Boolean
Set db = CurrentDb
Set rst = db.OpenRecordset("qryApproveHead"
If IsNull(Me![cmbPolicyTitle].Text) Then
txtPolicyNum = " "
rst.Close
Else
'find the record that matches the control.
rst.FindFirst "[PolicyTitle] = '" & PolicyTitle "'"
txtPolicyNum = rst!PolicyNum
'find the record that matches the control.
Me.RecordsetClone.FindFirst "[PolicyNum] = " & txtPolicyNum
Me.Bookmark = Me.RecordsetClone.Bookmark
tmp = Me.RecordsetClone.NoMatch
rst.Close
End If
If tmp Then
DoCmd.GoToRecord , , acNewRec
End If
cmbPolicyTitle.SetFocus
End Sub
If more info is needed please let me know. Thanks in advance.
nubianqueen