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

Can't access or update data from the database

Status
Not open for further replies.

tebza123

Programmer
Dec 1, 2004
3
0
0
ZA


I am trying to search and update data on my table but this error appears:No value given for one or more required parameters error number:2147217904

Here is the coding for Search

Set Rcustomer = New Recordset
Rcustomer.Open "SELECT * FROM backups WHERE [Serial_Number]=" & Text1.Text, conn

Text1.Text = Rcustomer![Serial_Number]
Text2.Text = Rcustomer![Brand_Make]
Text3.Text = Rcustomer![Barcode]
Text4.Text = Rcustomer![PC_Location]
Text5.Text = Rcustomer![Customer_name]
Text6.Text = Rcustomer![CustomerTelNo]
Combo1.Text = Rcustomer![Company]
Combo2.Text = Rcustomer![Company_Location]
Combo3.Text = Rcustomer![Technician]
Text7.Text = Rcustomer![Reason]
Text8.Text = Rcustomer![Date_brought_back]
Text9.Text = Rcustomer![Date_out]

MsgBox "Record Found", vbInformation

And for Update:
Set cmdbutton = New ADODB.Command
sql = " Update backups set [Serial_Number]=" & "'" & Text1.Text & "'"

sql = sql & "," & " [Serial_Number]= ' " & Text1.Text & " ' "
sql = sql & "," & " [Brand_Make]=' " & Text2.Text & " ' "
sql = sql & "," & " [Barcode]=' " & Text3.Text & " ' "
sql = sql & " ," & " [Location]= ' " & Text4.Text & " ' "
sql = sql & "," & " [Customer_name]=' " & Text5.Text & " ' "
sql = sql & "," & " [CustomerTelno]=' " & Text6.Text & " ' "
sql = sql & "," & " [Company]=' " & Combo1.Text & " ' "
sql = sql & "," & " [Company_Location]= ' " & Combo2.Text & " ' "
sql = sql & "," & " [Technician]=' " & Combo3.Text & " ' "
sql = sql & "," & " [Reason]=' " & Text7.Text & " ' "
sql = sql & "," & " [Date_brought_back]=' " & Text8.Text & " ' "
sql = sql & "," & " [Date_out]=' " & Text9.Text & " ' "

sql = sql & " where [Serial_Number]=" & Text1.Text
With cmdbutton
.ActiveConnection = cn
.CommandText = sql
.Execute
End With
MsgBox "Record Successfully Updated", vbInformation
Exit Sub

My fields are all text from the table there is no number

Please help me
Thanks

 
It looks like you need quotes surrounding your text1.text. Try something like:

Code:
sql = sql & " where [Serial_Number]=""" & Text1.Text & """"

Two quotes is the escape sequence for a quote. You might also be able to use single quote marks. Or, you can use Chr(34), as in:

Code:
sql = sql & " where [Serial_Number]=" & chr(34) & Text1.Text & chr(34)

I got this error when I was trying to give a sql string with a nonexistent field.

If I may be of any further assistance, please let me know.

Ahliana
Argue for your limitations and, sure enough, they're yours! - Richard Bach
 

Hi

I would like to thank each and everyone of you who responded to my mail it means a lot to me to know that some people actually care that enough to help

thank you very much

tebza123
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top