| | |
About Updating a Record in adodb
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2008
Posts: 161
Reputation:
Solved Threads: 1
Private Sub Command1_Click()
If Combo1.Text = "" Then
MsgBox "Please Choose Supplier Code", vbInformation
Combo1.SetFocus
Exit Sub
End If
If Combo2.Text = "" Then
MsgBox "Please Choose Product Code", vbInformation
Combo2.SetFocus
Exit Sub
End If
If Text1.Text = "" Then
MsgBox "Please Input the Quantity", vbInformation
Text1.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "Please Input the Amount", vbInformation
Text3.SetFocus
Exit Sub
End If
rs.Open "Insert Into Deliver (scode, pcode, quantity, unit, amount, pcarrier, pterms, drnumber, date) Values ('" + Combo1.Text + "','" + Combo2.Text + "','" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "','" + Text6.Text + "','" + Text7.Text + "')", cn, adOpenKeyset, adLockPessimistic
Set rs = Nothing
rs1.Open "select * from Product where pcode='" & Combo2.Text & "'", cn, adOpenKeyset, adLockPessimistic
If rs1.RecordCount > 0 Then
rs1.Fields![pstock] = Val(rs1.Fields![pstock]) + Val(Text1.Text)
rs1.Update
rs.Close
MsgBox "The Product has been save successfully", vbInformation
Combo1.Text = ""
Combo2.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Call Form_Load
Else
MsgBox "OHH NO!", vbInformation
End If
End Sub
i have a problem everytime i click my command1 button can anyone help me about my problem? please? badly needed rush! please help me god bless daniweb!
error is on about in INSERT INTO
If Combo1.Text = "" Then
MsgBox "Please Choose Supplier Code", vbInformation
Combo1.SetFocus
Exit Sub
End If
If Combo2.Text = "" Then
MsgBox "Please Choose Product Code", vbInformation
Combo2.SetFocus
Exit Sub
End If
If Text1.Text = "" Then
MsgBox "Please Input the Quantity", vbInformation
Text1.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "Please Input the Amount", vbInformation
Text3.SetFocus
Exit Sub
End If
rs.Open "Insert Into Deliver (scode, pcode, quantity, unit, amount, pcarrier, pterms, drnumber, date) Values ('" + Combo1.Text + "','" + Combo2.Text + "','" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "','" + Text6.Text + "','" + Text7.Text + "')", cn, adOpenKeyset, adLockPessimistic
Set rs = Nothing
rs1.Open "select * from Product where pcode='" & Combo2.Text & "'", cn, adOpenKeyset, adLockPessimistic
If rs1.RecordCount > 0 Then
rs1.Fields![pstock] = Val(rs1.Fields![pstock]) + Val(Text1.Text)
rs1.Update
rs.Close
MsgBox "The Product has been save successfully", vbInformation
Combo1.Text = ""
Combo2.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Call Form_Load
Else
MsgBox "OHH NO!", vbInformation
End If
End Sub
i have a problem everytime i click my command1 button can anyone help me about my problem? please? badly needed rush! please help me god bless daniweb!
error is on about in INSERT INTO
Last edited by ryan311; Dec 1st, 2008 at 7:45 am. Reason: i forgot something
Corrections
must be
and
must be
remove the statement
[code[
rs.close
[/code]
Regards
Shaik Akthar
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
rs.Open "Insert Into Deliver (scode, pcode, quantity, unit, amount, pcarrier, pterms, drnumber, date) Values ('" + Combo1.Text + "','" + Combo2.Text + "','" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "','" + Text6.Text + "','" + Text7.Text + "')", cn, adOpenKeyset, adLockPessimistic
must be
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
cn.Execute "Insert Into Deliver (scode, pcode, quantity, unit, amount, pcarrier, pterms, drnumber, date) Values ('" + Combo1.Text + "','" + Combo2.Text + "','" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "','" + Text6.Text + "','" + Text7.Text + "')"
and
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
rs1.Open "select * from Product where pcode='" & Combo2.Text & "'", cn, adOpenKeyset, adLockPessimistic
must be
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
rs1.Open "select * from Product where pcode='" & Combo2.Text & "'", cn, adOpenDynamic, adLockOptimistic
remove the statement
[code[
rs.close
[/code]
Regards
Shaik Akthar
Last edited by aktharshaik; Dec 1st, 2008 at 9:07 am.
check out the syntax. u have added single quotes to the numeric fields also. remove them.
I am unable to figure out the numeric fields from ur query, but that's the problem.
Put quotes for text fields and remove them for numeric fields.
Regards
Shaik Akthar
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
'" + Combo1.Text + "','" + Combo2.Text + "','" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "','" + Text6.Text + "','" + Text7.Text + "' 'must be '" + Combo1.Text + "','" + Combo2.Text + "'," + Text1.Text + "," + Text2.Text + "," + Text3.Text + "," + Text4.Text + "," + Text5.Text + "," + Text6.Text + "," + Text7.Text + ")"
I am unable to figure out the numeric fields from ur query, but that's the problem.
Put quotes for text fields and remove them for numeric fields.
Regards
Shaik Akthar
•
•
Join Date: Jul 2008
Posts: 161
Reputation:
Solved Threads: 1
If Combo1.Text = "" Then
MsgBox "Please Choose Supplier Code"
Combo1.SetFocus
Exit Sub
End If
If Combo2.Text = "" Then
MsgBox "Please Choose Product Code"
Combo2.SetFocus
Exit Sub
End If
If Text1.Text = "" Then
MsgBox "Please Input the Quantity"
Text1.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "Please Input the Amount"
Text3.SetFocus
Exit Sub
End If
cn.Execute "Insert Into Deliver (scode, pcode, quantity, unit, amount, pcarrier, pterms, drnumber, date) Values ('" + Combo1.Text + "','" + Combo2.Text + "'," + Text1.Text + "," + Text2.Text + "," + Text3.Text + "," + Text4.Text + "," + Text5.Text + "," + Text6.Text + "," + Text7.Text + ")", cn, adOpenKeyset, adLockPessimistic
rs1.Open "select * from Product where pcode='" & Combo2.Text & "'", cn, adOpenDynamic, adLockOptimistic
If rs1.RecordCount > 0 Then
rs1.Fields![pstock] = Val(rs1.Fields![pstock]) + Val(Text1.Text)
rs1.Update
rs1.Close
MsgBox "The Product has been save successfully", vbInformation
Combo1.Text = ""
Combo2.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Call Form_Load
Else
MsgBox "OHH NO!", vbInformation
End If
Compile Error:
wrong Number of agruments or invalid property assignment
MsgBox "Please Choose Supplier Code"
Combo1.SetFocus
Exit Sub
End If
If Combo2.Text = "" Then
MsgBox "Please Choose Product Code"
Combo2.SetFocus
Exit Sub
End If
If Text1.Text = "" Then
MsgBox "Please Input the Quantity"
Text1.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "Please Input the Amount"
Text3.SetFocus
Exit Sub
End If
cn.Execute "Insert Into Deliver (scode, pcode, quantity, unit, amount, pcarrier, pterms, drnumber, date) Values ('" + Combo1.Text + "','" + Combo2.Text + "'," + Text1.Text + "," + Text2.Text + "," + Text3.Text + "," + Text4.Text + "," + Text5.Text + "," + Text6.Text + "," + Text7.Text + ")", cn, adOpenKeyset, adLockPessimistic
rs1.Open "select * from Product where pcode='" & Combo2.Text & "'", cn, adOpenDynamic, adLockOptimistic
If rs1.RecordCount > 0 Then
rs1.Fields![pstock] = Val(rs1.Fields![pstock]) + Val(Text1.Text)
rs1.Update
rs1.Close
MsgBox "The Product has been save successfully", vbInformation
Combo1.Text = ""
Combo2.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Call Form_Load
Else
MsgBox "OHH NO!", vbInformation
End If
Compile Error:
wrong Number of agruments or invalid property assignment
Last edited by ryan311; Dec 1st, 2008 at 10:41 am. Reason: i forgot
![]() |
Similar Threads
- Updating columns in an access database using c# (C#)
- Read Me:Access to any type of DB's possible (Visual Basic 4 / 5 / 6)
- Updating an Access database with a secondary form (VB.NET)
- how to validate text file, loading into listbox (Visual Basic 4 / 5 / 6)
- need help in VB Code (MS Access and FileMaker Pro)
- Addnew problem (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Visual Basic 6 - Hide Folders
- Next Thread: Would like to get back VB ver 6.0 source code
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





