S
Stapes
Hi
I have a combo box with 3 columns that I want to allow the user to add
entries to. I tried adding an OnNotInList procedure, but it seems that
it processes my AfterUpdate procedure first.
I couldn't see how to add 3 columns of data here, so instead I open a
new form to allow the user to add the new record.
1. my calling procedure seems to carry on running. I was expecting it
to stop processing until the new form closed. This causes it to loop.
2. After adding a new record using the new form, I return and rerun my
query to find it, but it can't find the new record.
Here is my procedure: -
Private Sub Combo20_PartID_AfterUpdate()
On Error GoTo errCombo20_PartID_AfterUpdate
' set TXT_PartDesc and CUR_ItemPrice to values from TM_Parts depending
on PK_Part selected
Dim db As Database, qd As QueryDef, rs As Recordset, strSQL As String
Dim flag As Boolean
flag = False
Set db = CurrentDb
Set qd = db.QueryDefs("qryParts")
query_again:
qd.Parameters("pCO").Value = Me!Combo20_PartID
Set rs = qd.OpenRecordset
If rs.EOF And rs.BOF Then
If flag = True Then
GoTo errtrap
End If
Call NewPart
flag = True
GoTo query_again
Else
Me.TXT_PartDesc = rs!TXT_Detail
Me.CUR_ItemPrice = rs!CUR_Price
End If
Exit Sub
errtrap:
MsgBox "Loop"
Exit Sub
errCombo20_PartID_AfterUpdate:
MsgBox Err.Number & " " & Err.Description
End Sub
Private Sub NewPart()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "TM_Parts"
stLinkCriteria = ""
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
End Sub
Stapes
I have a combo box with 3 columns that I want to allow the user to add
entries to. I tried adding an OnNotInList procedure, but it seems that
it processes my AfterUpdate procedure first.
I couldn't see how to add 3 columns of data here, so instead I open a
new form to allow the user to add the new record.
1. my calling procedure seems to carry on running. I was expecting it
to stop processing until the new form closed. This causes it to loop.
2. After adding a new record using the new form, I return and rerun my
query to find it, but it can't find the new record.
Here is my procedure: -
Private Sub Combo20_PartID_AfterUpdate()
On Error GoTo errCombo20_PartID_AfterUpdate
' set TXT_PartDesc and CUR_ItemPrice to values from TM_Parts depending
on PK_Part selected
Dim db As Database, qd As QueryDef, rs As Recordset, strSQL As String
Dim flag As Boolean
flag = False
Set db = CurrentDb
Set qd = db.QueryDefs("qryParts")
query_again:
qd.Parameters("pCO").Value = Me!Combo20_PartID
Set rs = qd.OpenRecordset
If rs.EOF And rs.BOF Then
If flag = True Then
GoTo errtrap
End If
Call NewPart
flag = True
GoTo query_again
Else
Me.TXT_PartDesc = rs!TXT_Detail
Me.CUR_ItemPrice = rs!CUR_Price
End If
Exit Sub
errtrap:
MsgBox "Loop"
Exit Sub
errCombo20_PartID_AfterUpdate:
MsgBox Err.Number & " " & Err.Description
End Sub
Private Sub NewPart()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "TM_Parts"
stLinkCriteria = ""
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
End Sub
Stapes