What Could be wrong here!!!

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2009
Posts: 25
Reputation: Israelsimba is an unknown quantity at this point 
Solved Threads: 0
Israelsimba Israelsimba is offline Offline
Light Poster

What Could be wrong here!!!

 
0
  #1
Oct 22nd, 2009
i have been using adodc for searching for a client's details using the client number, but it would give me inexpected errors and bomb out of my programme. i have then resorted to searching using sql. the following code gives me this error:::

no value given for one or more required parameters

this error is pointed at line 7 in the following code.

the code thats producing this error is:::
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub cmdcnsearch_Click()
  2. sql = "Select companyname,companysize,country,city from cooperate where CSTR(accnumber)='" & txtcnsearch.Text & "'"
  3. Set conn = New Connection
  4. Set r = New Recordset
  5. conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Subscriptions Project\subscriptions.mdb"
  6. With r
  7. .Open sql, conn, adOpenKeyset, adLockOptimistic, adCmdText
  8. If .EOF Then
  9. MsgBox "Record not found", vbExclamation
  10. txtcnsearch.SelStart = 0
  11. txtcnsearch.SelLength = Len(txtcnsearch.Text)
  12. txtcnsearch.SetFocus
  13. Exit Sub
  14. 'to populate the field
  15. Else
  16. txtccname = r!CompanyName
  17. txtcsize.Text = r!companysize
  18. txtcountry.Text = r!country
  19. txtcity.Text = r!city
  20. r.Close
  21.  
  22. End If
  23. End With
  24. End Sub
can you help me please!!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 25
Reputation: Israelsimba is an unknown quantity at this point 
Solved Threads: 0
Israelsimba Israelsimba is offline Offline
Light Poster
 
0
  #2
Oct 22nd, 2009
since im the one who posted this thread let me just add on something.
i have tried a different method for searching and its now telling me another different error. the error is::
object variable or with block variable not set

the code thats giving this error is:::::

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim uid As Variant
  2. uid = txtcnamesearch
  3. If uid = "" Then Exit Sub
  4. r.Find "membernumber=" & uid
  5. If r.EOF = True Then
  6. mymessage = MsgBox("Account does not exist, Please create account first", vbCritical, "Account Not Found")
  7. txtcnamesearch = ""
  8. txtcnamesearch.SetFocus
  9. r.MoveFirst
  10. Else
  11. txtccname = r("companyname")
  12. txtcsize = r("companysize")
  13. txtccountry = r("country")
  14. End If
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 25
Reputation: Israelsimba is an unknown quantity at this point 
Solved Threads: 0
Israelsimba Israelsimba is offline Offline
Light Poster
 
0
  #3
Oct 22nd, 2009
since im the one who posted this thread let me just add on something.
i have tried a different method for searching and its now telling me another different error. the error is::
object variable or with block variable not set

the code thats giving this error is:::::

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim uid As Variant
  2. uid = txtcnamesearch
  3. If uid = "" Then Exit Sub
  4. r.Find "membernumber=" & uid
  5. If r.EOF = True Then
  6. mymessage = MsgBox("Account does not exist, Please create account first", vbCritical, "Account Not Found")
  7. txtcnamesearch = ""
  8. txtcnamesearch.SetFocus
  9. r.MoveFirst
  10. Else
  11. txtccname = r("companyname")
  12. txtcsize = r("companysize")
  13. txtccountry = r("country")
  14. End If
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 505
Reputation: abu taher is an unknown quantity at this point 
Solved Threads: 26
abu taher's Avatar
abu taher abu taher is offline Offline
Posting Pro
 
0
  #4
Oct 22nd, 2009
plz check it with more.
Attached Files
File Type: zip SEARCH.zip (38.4 KB, 1 views)
I like sword. Attack or Defense.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 25
Reputation: Israelsimba is an unknown quantity at this point 
Solved Threads: 0
Israelsimba Israelsimba is offline Offline
Light Poster
 
0
  #5
Oct 22nd, 2009
sorry but i am using VB 6 and cant access the file u sent me...think its PHP and cant link it with VB...please i ned to search using VB thanx for your help
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1
Reputation: shh22 is an unknown quantity at this point 
Solved Threads: 1
shh22 shh22 is offline Offline
Newbie Poster
 
0
  #6
Oct 22nd, 2009
Try placing brackets around CSTR(accnumber) so it looks like this:

[CSTR(accnumber)]

I'm assuming it's the name of a field.


Originally Posted by Israelsimba View Post
i have been using adodc for searching for a client's details using the client number, but it would give me inexpected errors and bomb out of my programme. i have then resorted to searching using sql. the following code gives me this error:::

no value given for one or more required parameters

this error is pointed at line 7 in the following code.

the code thats producing this error is:::
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub cmdcnsearch_Click()
  2. sql = "Select companyname,companysize,country,city from cooperate where CSTR(accnumber)='" & txtcnsearch.Text & "'"
  3. Set conn = New Connection
  4. Set r = New Recordset
  5. conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Subscriptions Project\subscriptions.mdb"
  6. With r
  7. .Open sql, conn, adOpenKeyset, adLockOptimistic, adCmdText
  8. If .EOF Then
  9. MsgBox "Record not found", vbExclamation
  10. txtcnsearch.SelStart = 0
  11. txtcnsearch.SelLength = Len(txtcnsearch.Text)
  12. txtcnsearch.SetFocus
  13. Exit Sub
  14. 'to populate the field
  15. Else
  16. txtccname = r!CompanyName
  17. txtcsize.Text = r!companysize
  18. txtcountry.Text = r!country
  19. txtcity.Text = r!city
  20. r.Close
  21.  
  22. End If
  23. End With
  24. End Sub
can you help me please!!!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 255
Reputation: AndreRet is an unknown quantity at this point 
Solved Threads: 38
AndreRet AndreRet is offline Offline
Posting Whiz in Training
 
0
  #7
Oct 22nd, 2009
Follow my comment lines within your code...

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub cmdcnsearch_Click()
  2. 'dim sql as string
  3.  
  4. sql = "Select companyname,companysize,country,city from cooperate where CSTR(accnumber)='" & txtcnsearch.Text & "'"
  5. 'sql = "Select companyname,companysize,country,city from 'cooperate where accnumber=" & "'" & txtcnsearch.Text & "'"
  6. 'remove the cstr for the value you are looking for is in a field, which 'is the value that will be returned.
  7.  
  8. Set conn = New Connection
  9.  
  10. Set r = New Recordset
  11. conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Subscriptions Project\subscriptions.mdb"
  12. With r
  13. .Open sql, conn, adOpenKeyset, adLockOptimistic, adCmdText
  14. If .EOF Then
  15. MsgBox "Record not found", vbExclamation
  16. txtcnsearch.SelStart = 0
  17. txtcnsearch.SelLength = Len(txtcnsearch.Text)
  18. txtcnsearch.SetFocus
  19. Exit Sub
  20. 'to populate the field
  21. Else
  22. txtccname = r!CompanyName
  23. txtcsize.Text = r!companysize
  24. txtcountry.Text = r!country
  25. txtcity.Text = r!city
  26. r.Close
  27.  
  28. End If
  29. End With
  30. End Sub

Hope this solves your problem. With your second error, is your connection referenced?
Please mark questions as answered when done.

Be the ONE!!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 25
Reputation: Israelsimba is an unknown quantity at this point 
Solved Threads: 0
Israelsimba Israelsimba is offline Offline
Light Poster
 
0
  #8
Oct 22nd, 2009
when i make the changes it gives me a whole new error...its now saying

syntax error in querry. Incomplete query close

and its pointing to the following section of my code....

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. With r
  2. .Open sql, conn, adOpenKeyset, adLockOptimistic, adCmdText

so what could be causing that.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 25
Reputation: Israelsimba is an unknown quantity at this point 
Solved Threads: 0
Israelsimba Israelsimba is offline Offline
Light Poster
 
0
  #9
Oct 22nd, 2009
thanx AndreRet!!!!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 25
Reputation: Israelsimba is an unknown quantity at this point 
Solved Threads: 0
Israelsimba Israelsimba is offline Offline
Light Poster
 
0
  #10
Oct 22nd, 2009
wheh i make the chaanges it gives me a different error.....now it is saying...

syntax error in querry.Incomplete querry close!

and this error is highlighting the following
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 474 | Replies: 11
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC