Hi I got some vba script and but function IIF not working please help
Dim stDocName As String
Dim prodtype As String
Dim prod As String
Dim copies As String
copies = DLookup("scheme__ProductionPlan.template_copies", "scheme__ProductionPlan", "scheme__ProductionPlan.seq = [seq] And scheme__ProductionPlan.line = '02' And scheme__ProductionPlan.reqd_date = [Forms]![Production Plan]![Text5]")
prod = Forms![Production Plan]![Line02 subform].Form.Combo38
prodtype = DLookup("analysis_a", "scheme_stockm", "product= '" & Forms![Production Plan]![Line02 subform].Form.Combo38 & "' and warehouse= 'FG'")
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete from SeqNo where 1=1"
DoCmd.RunSQL "insert into SeqNo (SequenceNo) values (" & seq & ")"
DoCmd.RunSQL "update scheme__ProductionPlan set template_copies = template_copies+1 where reqd_date = [Forms]![Production Plan]![Text5] and line = '02' and seq = (" & seq & ")"
If Trim(copies) = 2 Or Trim(copies) > 2 Then
MsgBox "Litmit copies is two"
Me.Command49.SetFocus
ElseIf Trim(prodtype) = "Residual" Then
stDocName = "ProdRunSheet Resid Line02"
Else
stDocName = "ProdRunSheet Line02"
End If
DoCmd.OpenReport stDocName, acNormal
Dim stDocName As String
Dim prodtype As String
Dim prod As String
Dim copies As String
copies = DLookup("scheme__ProductionPlan.template_copies", "scheme__ProductionPlan", "scheme__ProductionPlan.seq = [seq] And scheme__ProductionPlan.line = '02' And scheme__ProductionPlan.reqd_date = [Forms]![Production Plan]![Text5]")
prod = Forms![Production Plan]![Line02 subform].Form.Combo38
prodtype = DLookup("analysis_a", "scheme_stockm", "product= '" & Forms![Production Plan]![Line02 subform].Form.Combo38 & "' and warehouse= 'FG'")
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete from SeqNo where 1=1"
DoCmd.RunSQL "insert into SeqNo (SequenceNo) values (" & seq & ")"
DoCmd.RunSQL "update scheme__ProductionPlan set template_copies = template_copies+1 where reqd_date = [Forms]![Production Plan]![Text5] and line = '02' and seq = (" & seq & ")"
If Trim(copies) = 2 Or Trim(copies) > 2 Then
MsgBox "Litmit copies is two"
Me.Command49.SetFocus
ElseIf Trim(prodtype) = "Residual" Then
stDocName = "ProdRunSheet Resid Line02"
Else
stDocName = "ProdRunSheet Line02"
End If
DoCmd.OpenReport stDocName, acNormal