M
mattc66 via AccessMonster.com
Below Code is not working. I have used this code before - so I am not sure
what is wrong. In the LookUpItem drop down I have added the AfterUpdate
command. If it find the item in the drop down box it goes to that record. If
it doesn't find the item in the drop down it adds that item.
Private Sub LookUpItem_AfterUpdate()
Dim SID As String
Dim rsc As DAO.Recordset
Dim db As Database
Set rsc = Me.RecordsetClone
Set db = CurrentDb
SID = Me.LookUpItem.Value
'Record not found add record
If DCount("ItemComponent", "tblItemComponent", SID) = 0 Then
DoCmd.GoToRecord , , acNewRec
Me.ItemComponent = Me.LookUpItem.Column(0)
Me.ItemDescription = Me.LookUpItem.Column(1)
Me.Refresh
ElseIf DCount("ItemComponent", "tblItemComponent", SID) >= 1 Then
'Go to record of original Number
rsc.FindFirst SID
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
what is wrong. In the LookUpItem drop down I have added the AfterUpdate
command. If it find the item in the drop down box it goes to that record. If
it doesn't find the item in the drop down it adds that item.
Private Sub LookUpItem_AfterUpdate()
Dim SID As String
Dim rsc As DAO.Recordset
Dim db As Database
Set rsc = Me.RecordsetClone
Set db = CurrentDb
SID = Me.LookUpItem.Value
'Record not found add record
If DCount("ItemComponent", "tblItemComponent", SID) = 0 Then
DoCmd.GoToRecord , , acNewRec
Me.ItemComponent = Me.LookUpItem.Column(0)
Me.ItemDescription = Me.LookUpItem.Column(1)
Me.Refresh
ElseIf DCount("ItemComponent", "tblItemComponent", SID) >= 1 Then
'Go to record of original Number
rsc.FindFirst SID
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub