#Error in text box (1 Viewer)

eason

Registered User.
Local time
Today, 08:02
Joined
Nov 3, 1999
Messages
31
I have a text box were the control source is =Getusrlbl1([sam_id]). When the VBA runs I get a #Error on my report. The code is:
Private Function Getusrlbl1 (id As String)
On Error Resume Next
Dim rst As Recordset
Dim stSQL AS String

stSQL = "Select usrlbl1 form qurPCincompleteTest where sam_id=" &id
Set rst = currentdb.OpenRecordset(stSQL)
rst.MoveFirst
ect.....
Dose anyone have an idea why I'm getting and #Error on my report?? sam_id is on the report.

I found the answer today. Yes it is a string because the text is alphanumerica with a - in it. Long was the reason I was getting and #Error. Also at the end of the stSQL statement I did not have it right. It should be:

stSQK = "Select usrlbl1 form qurPCincompleteTest where sam_id='" &id&"'"
Thanks for the suggestions.

[This message has been edited by eason (edited 01-06-2000).]
 

Travis

Registered User.
Local time
Today, 06:02
Joined
Dec 17, 1999
Messages
1,332
This is just a guess, but:
Private Function Getusrlbl1 (id As String)

Is id suppose to be a String or is it a Long?

If it's suppose to be a long it will error out.
 

Users who are viewing this thread

Top Bottom