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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does code not work 1

Status
Not open for further replies.

Saturn57

Programmer
Joined
Aug 30, 2007
Messages
275
Location
CA
I have the following code and it always gets stopped at the line "PrintWRNo = (PrintWRNo + 1)" can anyone tell me why?

Private Sub Command3_Click()
PrintWRNo = Me.StartJobNo

While (PrintWRNo <= Me.EndJobNo)
[Forms]![SpecificJobForm]![PrintJob] = PrintWRNo
DoCmd.OpenReport "WorkReleases Specific Job", acViewNormal
DoCmd.Close acReport, "WorkReleases Specific Job"
PrintWRNo = (PrintWRNo + 1)
Wend
End Sub
 
What data type is PrintWRNo defined as?

My guess is it is declared as a text variable, and you can't increment a text variable with a number.

John
 
Do you mean
Dim PrintWRNo As String
 
Yes - that's it.

If you change that line to

Dim PrintWRNo As Integer

and the first line to:

PrintWRNo = CInt (Me.StartJobNo)

then it should be fine.

John
 
This field is a combination of letters and numbers.
ex JD00798. Is there a way to increment this to JD00799, JD00800 etc...
 
What about something like this ?
Code:
PrintWRNo = Left(PrintWRNo, Len(PrintWRNo) - 5) & Format(1 + Right(PrintWRNo, 5), "00000")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top