syntax problem - data no found

S

SIN

hi all,
i have error message - Too few parameters - but the record existent so i
think that the problem on the syntax:

Private Sub CmdExecute_Click()
Dim dbs As Database
Dim rsSupplier As Recordset
Dim strSQL As String

Set dbs = CurrentDb()
strSQL = "SELECT * from Supplier "
strSQL = strSQL & " where supplier_name = " & Me!Supplier_Name

Set rsSupplier = dbs.OpenRecordset(strSQL)
rsSupplier.Close
Set cn = Nothing

End Sub
 
R

Rob Parker

If supplier_name is a text string (as I would strongly suspect), then you
need string delimiters around your Where parameter:

strSQL = strSQL & " where supplier_name = '" & Me!Supplier_Name & "'"

If Supplier_name may contain a single-quote character (also used as and
apostrophe in a name suach as O'Neill) this will give an error; if so, you
can use a pair of double-quote characters as the delimiter:


strSQL = strSQL & " where supplier_name = """ & Me!Supplier_Name & """"

HTH,

Rob
 
R

Rob Parker

If Supplier_Name is a text field (as I strongly suspect), then you need
string delimiters around the parameter in your Where clause:

strSQL = strSQL & " where supplier_name = '" & Me!Supplier_Name & "'"

Also, if your Supplier_Name may contain a single-quote (apostrophe)
character, you should use a pair of double-quote characters as the
delimiters:

strSQL = strSQL & " where supplier_name = """ & Me!Supplier_Name & """"


HTH,

Rob
 
S

SIN

Thanks, but is not working.
me!supplier_name = this is the record: Form - of table import_invoice.

in that way is working!!!
strSQL = "SELECT * from Supplier where supplier_name = (select supplier_name
from import_invoice)"
 
D

Douglas J. Steele

It's not clear to me what you're saying is working, and what you're saying
isn't working.

However, assuming that what you've got for strSQL isn't working, try:

strSQL = "SELECT * from Supplier where supplier_name IN (select
supplier_name from import_invoice)"
 
B

B.J Wallace

How do you set your mail header to receive mail from all of your e-mail
adresses?
 
S

SIN

Sorry, my english no nuch ):
i try to explan again.
when i create that select:
strSQL = "SELECT * from Supplier where supplier_name = '" & Me!Supplier_Name
& "'"
even :
strSQL = "SELECT * from Supplier where supplier_id = '" & Me!Supplier_id &
"'"
i get error: Too few parameters .
i quite sure that the mistake in the syntax.
thanks ):
 
D

Douglas J. Steele

Assuming supplier_name is a text field, then the following should work:

strSQL = "SELECT * from Supplier " & _
"where supplier_name = '" & Me!Supplier_name & "'"

Similarly, if supplier_id is a text field, then this should work:

strSQL = "SELECT * from Supplier " & _
"where supplier_id = '" & Me!Supplier_id & "'"

The most common mistake is mispelling the name of the field (or of the
table).
 
S

SIN

TNANKS, I'TS WORKING :)))))))))

Douglas J. Steele said:
Assuming supplier_name is a text field, then the following should work:

strSQL = "SELECT * from Supplier " & _
"where supplier_name = '" & Me!Supplier_name & "'"

Similarly, if supplier_id is a text field, then this should work:

strSQL = "SELECT * from Supplier " & _
"where supplier_id = '" & Me!Supplier_id & "'"

The most common mistake is mispelling the name of the field (or of the
table).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top