W
Will G
I want to add a line of code to this code bellow that checks if the record
already exists. can anyone help me.
Dim varItem As Variant 'Selected items
Dim strWhere As String 'String to use as WhereCondition
Dim strDescrip As String 'Description of WhereCondition
Dim lngLen As Long 'Length of string
Dim strDelim As String 'Delimiter for this field type.
Dim strDoc As String 'Name of report to open.
Dim strLabel As String
'Dim prm_sched As Control
' Dim DBS As Database
'Dim rst As Recordset
Dim quantity As Double
Dim resp As String
Dim DBS As Database
'Dim rst As Recordset
Dim strSel As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
quantity = Me.sched.Column(5)
'Set prm_sched = Me![sched]
If Me.sched.ItemsSelected.Count = 0 Then
Beep
MsgBox "no item selected ", 48
Exit Sub
End If
'Set DBS = CodeDb
' Set rst = DBS.OpenRecordset("SELECT * FROM POhistory")
Set db = CurrentDb
Set rst = db.OpenRecordset("ProdHistory")
'run through all selected items
For Each itm In Me.sched.ItemsSelected
rst.AddNew
rst.Fields("OrderNo") = Me.sched.ItemData(itm)
'rst!RequiredDate = prm_sched.Column(1)
rst.Fields("RequiredDate") = Me.sched.Column(1, itm)
rst.Fields("CustomerID") = Me.sched.Column(2, itm)
'rst!CustomerID = prm_sched.Column(2)
rst.Fields("ModelNumber") = Me.sched.Column(3, itm)
'rst!ModelNumber = prm_sched.Column(3)
rst.Fields("Description") = Me.sched.Column(4, itm)
rst.Fields("OrderQty") = Me.sched.Column(5, itm)
rst.Fields("Comment") = Me.sched.Column(6, itm)
rst.Fields("Bfill") = Me.sched.Column(7, itm)
'rst!Bfill = prm_sched.Column(7)
rst.Fields("Qfill") = Me.sched.Column(8, itm)
rst.Fields("Uphfill") = Me.sched.Column(9, itm)
rst.Fields("Ptfill") = Me.sched.Column(10, itm)
rst.Fields("Spring") = Me.sched.Column(11, itm)
rst.Fields("Label") = Me.sched.Column(12, itm)
rst.Fields("Size") = Me.sched.Column(13, itm)
rst.Fields("Needle") = Me.sched.Column(14, itm)
rst.Fields("Pattern") = Me.sched.Column(15, itm)
rst.Fields("Config") = Me.sched.Column(16, itm)
rst.Fields("Border") = Me.sched.Column(17, itm)
rst.Fields("FoamCore") = Me.sched.Column(18, itm)
rst.Fields("FoamEnc") = Me.sched.Column(19, itm)
rst.Fields("ProtoTypeNum") = Me.sched.Column(22, itm)
rst.Fields("Color") = Me.txtColor
rst.Fields("Type") = Me.cmbType
rst.Fields("ProductionDate") = Me.Combo68
rst.update
strSel = "'" & Me.sched.ItemData(itm) & "',"
Next
' rst.AddNew
' rst.Fields("Color") = Me.Combo72
'rst.update
rst.close
Set rst = Nothing
Set db = Nothing
already exists. can anyone help me.
Dim varItem As Variant 'Selected items
Dim strWhere As String 'String to use as WhereCondition
Dim strDescrip As String 'Description of WhereCondition
Dim lngLen As Long 'Length of string
Dim strDelim As String 'Delimiter for this field type.
Dim strDoc As String 'Name of report to open.
Dim strLabel As String
'Dim prm_sched As Control
' Dim DBS As Database
'Dim rst As Recordset
Dim quantity As Double
Dim resp As String
Dim DBS As Database
'Dim rst As Recordset
Dim strSel As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
quantity = Me.sched.Column(5)
'Set prm_sched = Me![sched]
If Me.sched.ItemsSelected.Count = 0 Then
Beep
MsgBox "no item selected ", 48
Exit Sub
End If
'Set DBS = CodeDb
' Set rst = DBS.OpenRecordset("SELECT * FROM POhistory")
Set db = CurrentDb
Set rst = db.OpenRecordset("ProdHistory")
'run through all selected items
For Each itm In Me.sched.ItemsSelected
rst.AddNew
rst.Fields("OrderNo") = Me.sched.ItemData(itm)
'rst!RequiredDate = prm_sched.Column(1)
rst.Fields("RequiredDate") = Me.sched.Column(1, itm)
rst.Fields("CustomerID") = Me.sched.Column(2, itm)
'rst!CustomerID = prm_sched.Column(2)
rst.Fields("ModelNumber") = Me.sched.Column(3, itm)
'rst!ModelNumber = prm_sched.Column(3)
rst.Fields("Description") = Me.sched.Column(4, itm)
rst.Fields("OrderQty") = Me.sched.Column(5, itm)
rst.Fields("Comment") = Me.sched.Column(6, itm)
rst.Fields("Bfill") = Me.sched.Column(7, itm)
'rst!Bfill = prm_sched.Column(7)
rst.Fields("Qfill") = Me.sched.Column(8, itm)
rst.Fields("Uphfill") = Me.sched.Column(9, itm)
rst.Fields("Ptfill") = Me.sched.Column(10, itm)
rst.Fields("Spring") = Me.sched.Column(11, itm)
rst.Fields("Label") = Me.sched.Column(12, itm)
rst.Fields("Size") = Me.sched.Column(13, itm)
rst.Fields("Needle") = Me.sched.Column(14, itm)
rst.Fields("Pattern") = Me.sched.Column(15, itm)
rst.Fields("Config") = Me.sched.Column(16, itm)
rst.Fields("Border") = Me.sched.Column(17, itm)
rst.Fields("FoamCore") = Me.sched.Column(18, itm)
rst.Fields("FoamEnc") = Me.sched.Column(19, itm)
rst.Fields("ProtoTypeNum") = Me.sched.Column(22, itm)
rst.Fields("Color") = Me.txtColor
rst.Fields("Type") = Me.cmbType
rst.Fields("ProductionDate") = Me.Combo68
rst.update
strSel = "'" & Me.sched.ItemData(itm) & "',"
Next
' rst.AddNew
' rst.Fields("Color") = Me.Combo72
'rst.update
rst.close
Set rst = Nothing
Set db = Nothing