Problem with function IIF

krzysiekk

Registered User.
Local time
Today, 05:53
Joined
Dec 2, 2009
Messages
74
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
 
In what way is it not working?

Are you getting an error? If so, which line?

Or is the code doing something you are not expecting?
 
always showing MsgBox "Litmit copies is two" and next message "the action or method requires a Report Name argument"

when I press ok nothing happening.

looks like function iif not working.
 
The first message must be appearing because the value of copies it 2 or greater.

The second message is because you haven't assigned a value to stDocName so the line "DoCmd.OpenReport stDocName, acNormal" will not work.

hth
Chris
 

Users who are viewing this thread

Back
Top Bottom