Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute sub of Module X as part of sub for Form A code

Status
Not open for further replies.

KUZZ

Technical User
Aug 13, 2002
254
GB

this is a portion of the code from my form
============================================
' NEW JOBORDER

If Text14 = "STRT" Then
If Left(Text16, 2) = "CI" Or Left(Text16, 2) = "CP" Or Left(Text16, 2) = "C2" Or Left(Text16, 4) = "PROT" Or Left(Text16, 4) = "PROD" Then

?????????????????????????????????????????

If TOTRECS <> 0 Then
MsgBox &quot;THERE ARE &quot; & TOTRECS & &quot; JOBORDERS OPEN&quot;, vbOK + vbExclamation
Exit Sub
End If

DoCmd.GoToRecord , , acNewRec
If Text16 = &quot;PRODUCTION&quot; Or Text16 = &quot;PROTOTYPING&quot; Then
[JO#] = Text16
Else
[JO#] = Mid(Text16, 2)
End If
CI = Text16
MSETUOPER = Text12
JOST = &quot;OPEN&quot;
INI = Text12
CO = Text12
TAR = &quot; &quot;
[tblTIME.PT#] = [tblACTIONS.PT#]
[tblTIME.REV] = &quot; & [tblACTIONS.REV] & &quot;
Text12.SetFocus
===================================================



where you see many ?????'es i want to calculate a value TOTRECS by running sub from my module called ommon_operations, here is the sub


============================================

Public sub ACTIVE_JO_COUNT()

reccnt = Text209
OPNrecs = 0
TOTRECS = 0
Forms!TIMECAPTURE.SetFocus

DoCmd.GoToRecord , , acFirst
While reccnt > 0
If INI = Text12 Then

If ((MRUNST > MRUNEND) Or (Format(MRUNST, &quot;@&quot;) <> &quot;&quot; And Format(MRUNEND, &quot;@&quot;) = &quot;&quot;)) Or ((MSETST > MSETEND) Or (Format(MSETST, &quot;@&quot;) <> &quot;&quot; And Format(MSETEND, &quot;@&quot;) = &quot;&quot;)) Or ((FINST > FINEND) Or (Format(FINST, &quot;@&quot;) <> &quot;&quot; And Format(FINEND, &quot;@&quot;) = &quot;&quot;)) Or ((PNTST > PNTEND) Or (Format(PNTST, &quot;@&quot;) <> &quot;&quot; And Format(PNTEND, &quot;@&quot;) = &quot;&quot;)) Then

OPNrecs = 1 + OPNrecs

End If

TOTRECS = 1 + TOTRECS

End If

reccnt = reccnt - 1
DoCmd.GoToRecord , , acNext

Wend

so what do I have to write in the line instead of ??????????
so that the calculation of TOTORECS will take place and then the value would be used further in the code of my form A.

Good luck,
Kuzz

&quot;Time spent debating the impossible subtracts from the time during which you
can try to accomplish it.&quot;
 
You could do what you want as a sub, but you could also do it as a function. Assume TOTRECS represents an integer. Then the Function would look like this:

Public Function ACTIVE_JO_COUNT() as Integer

reccnt = Text209
OPNrecs = 0
TOTRECS = 0
Forms!TIMECAPTURE.SetFocus

DoCmd.GoToRecord , , acFirst
While reccnt > 0
If INI = Text12 Then

If ((MRUNST > MRUNEND) Or (Format(MRUNST, &quot;@&quot;) <> &quot;&quot; And Format(MRUNEND, &quot;@&quot;) = &quot;&quot;)) Or ((MSETST > MSETEND) Or (Format(MSETST, &quot;@&quot;) <> &quot;&quot; And Format(MSETEND, &quot;@&quot;) = &quot;&quot;)) Or ((FINST > FINEND) Or (Format(FINST, &quot;@&quot;) <> &quot;&quot; And Format(FINEND, &quot;@&quot;) = &quot;&quot;)) Or ((PNTST > PNTEND) Or (Format(PNTST, &quot;@&quot;) <> &quot;&quot; And Format(PNTEND, &quot;@&quot;) = &quot;&quot;)) Then

OPNrecs = 1 + OPNrecs

End If

TOTRECS = 1 + TOTRECS

End If

reccnt = reccnt - 1
DoCmd.GoToRecord , , acNext

Wend

ACTIVE_JO_COUNT = TOTRECS

End Function

Your code would then look like this:

If Text14 = &quot;STRT&quot; Then
If Left(Text16, 2) = &quot;CI&quot; Or Left(Text16, 2) = &quot;CP&quot; Or Left(Text16, 2) = &quot;C2&quot; Or Left(Text16, 4) = &quot;PROT&quot; Or Left(Text16, 4) = &quot;PROD&quot; Then

TOTRECS = ACTIVE_JO_COUNT

If TOTRECS <> 0 Then
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top