Run-time error don't understand

Carl Foster

Registered User.
Local time
Today, 23:05
Joined
May 29, 2006
Messages
72
Hi, hope you can help with this problem.

Here's the code to open a recordset.

Code:
Dim rsWorkgroups As New ADODB.Recordset
Dim SQLStmt As String

SQLStmt = "SELECT * FROM tblWorkgroups WHERE chrWorkgroupName = " & Me.tblCustomers_chrWorkgroup

rsWorkgroups.Open SQLStmt, CurrentProject.Connection, adOpenDynamic, adLockOptimistic

When it gets to the "rsWorkgroups.Open" statement, an error comes up saying:

Run-time error '-2147217904 (80040e10)
"No value given for one or more required parameters"

I can't see where any required parameters are missing from the code. Am I missing something?
 
If Me.tblCustomers_chrWorkgroup is a string then you will need to surround it with apostrophes...

Code:
SQLStmt = "SELECT * FROM tblWorkgroups WHERE chrWorkgroupName = '" & Me.tblCustomers_chrWorkgroup & "'"

Regards,
Tim
 
to elaborate, what happened was you put a string within the SQL string, that you wanted to be literal and you didn't surround it by apostrophese.

as with most programming the two statements 'text1' and text1 are completely different. where the first represents a string of "text1" while the second represents a variable with the name of text1.
 
Me.tblCustomers_chrWorkgroup is the name of a textbox within the form, so not a string.
 
Let me say the same thing in a different way. If the data type of chrWorkgroupName in the table is text (string) rather than numeric, you'll need to surround the value with single quotes as already pointed out.
 
pbaldy said:
Let me say the same thing in a different way. If the data type of chrWorkgroupName in the table is text (string) rather than numeric, you'll need to surround the value with single quotes as already pointed out.

What he said...;)
 

Users who are viewing this thread

Back
Top Bottom