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

Invalid Procedure or Call Argument 2

Status
Not open for further replies.

LittleMan22

Technical User
Jun 24, 2001
46
0
0
CA
Hi what's wrong with my code:
Dim rst As Recordset
Dim strComment As String

Set rst = CurrentDb.OpenRecordset("CurrentClientApplicationDataPolicies")

With rst
Do Until .EOF
strcomment = strcomment & !Carrier & " " & !PolicyNumber & " " & Format(!Amount, "$#,###") & "; "
.MoveNext
Loop
.Close
End With
Me.Remarks1 = Left(strcomment, Len(strcomment) - 3).

I keep getting the erorr Invalid Procedure Call or Argument and I can trap it to the line: Me.Remarks1 = ....

Any help would be greatly appreciated,
Ryan.

 
Ryan,
Me.Remarks1 = Left(strcomment, Len(strcomment) - 3
If len(strcomment) less than 3 to begin with, then you'll get this error, since you can't use negative in Left().
--Jim
 
The problem occurs when the recordset is empty.

How can I fix this?
 
How about:

Do Until .EOF
strcomment = strcomment & !Carrier & " " & !PolicyNumber & " " & Format(!Amount, "$#,###") & "; "
.MoveNext
Loop
.Close
End With

if strComment=&quot;&quot; or len(strcomment) < 3 then
else
Me.Remarks1 = Left(strcomment, Len(strcomment) - 3).
end if Hope this is ok. If not, just let me know.

Nick (Everton Rool OK!)
 
Ryan,
I wouldn't put any 'Do Until Rst...' statement until you check .Eof and .Bof first:

If rst.eof and rst.bof then 'then it's empty
'drop to exit, warn user, whatever...
Else
Rst.MoveFirst
Do Until Rst.Eof
blah, blah,

End if
--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top