473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

addnew dropdown box error (newbie)

3
The following is the code I am using for the addnew and the select clause:

Expand|Select|Wrap|Line Numbers
  1. <%Option Explicit%>
  2. <%
  3. IF session("sessionID") = "" THEN
  4. Response.Redirect "adminLogin.asp"
  5. END IF
  6. %>
  7.  
  8. <%
  9. If Request.Form("action")="add" Then
  10. If Request.Form("name") = "" Then _
  11. strError2 = strError2 & " - Please insert a name." & vbNewLine
  12. If Request.Form("team") = "" Then _
  13. strError1 = strError1 & " - Please insert a team." & vbNewLine
  14. IF strError1 = "" AND strError2 = "" Then
  15. %>
  16. <%
  17. If rscuafc.EOF and rscuafc.BOF THEN
  18. rscuafc.AddNew
  19. rscuafc.Fields("team") = Request.Form("team")
  20. rscuafc.Fields("name") = Request.Form("name")
  21. rscuafc.Fields("position") = Request.Form("position")
  22. rscuafc.Fields("email") = Request.Form("email")
  23. rscuafc.Fields("phone") = Request.Form("phone")
  24. rscuafc.Fields("goals") = Request.Form("goals")
  25. rscuafc.Fields("mobile") = Request.Form("mobile")
  26. rscuafc.Fields("street") = Request.Form("street")
  27. rscuafc.Fields("suburb") = Request.Form("suburb")
  28. rscuafc.Fields("city") = Request.Form("city")
  29. rscuafc.Fields("nationality") = Request.Form("nationality")
  30. rscuafc.Update
  31. Response.Redirect ("adminAddPlayerComplete.asp")
  32. Else
  33. strError = " - Failed, Please try again."
  34. END IF
  35. END IF
  36. END IF
  37. %>
  38. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  39. <html>
  40. <head>
  41. <!-- #INCLUDE file="includes/metatags.asp" -->
  42. </head>
  43. <body>
  44. <%
  45. Dim adoCon, rscuafc, strSQL, strError, strError1, strError2
  46. %>
  47. <%
  48. Set adoCon = Server.CreateObject("ADODB.Connection")
  49. adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; Dbq=\\Puafo\vaio (d)\puafo\clients\Christchurch United Soccer\cuafc.mdb;"
  50. Set rscuafc = Server.CreateObject("ADODB.Recordset")
  51. %>
  52. <%
  53. if Request.Form("name") >"" then
  54.     strSQL = "SELECT players.*, teams.* FROM players LEFT JOIN teams ON players.team=teams.team WHERE (((players.name)='" & Request.Form("name") & "')) ;"
  55. else
  56.     strSQL = "SELECT DISTINCT teams.team FROM teams;"    
  57. end if
  58. rscuafc.CursorType = 2
  59. rscuafc.LockType = 3
  60. rscuafc.Open strSQL, adoCon
  61. %>
Everything works the drop down box is populated from a different table, but when you submit the form to add the new record it kicks up the following error:

Expand|Select|Wrap|Line Numbers
  1. Microsoft VBScript runtime (0x800A01A8)
  2. Object required: ''
  3. /adminAddPlayer.asp, line 17
The following is line 17

Expand|Select|Wrap|Line Numbers
  1. If rscuafc.EOF and rscuafc.BOF THEN
Any pointers would be greatly appreciated thanks in advance.
Apr 14 '07 #1
1 1457
In line 17 you make use of the rscuafc object (the recordset) but it is declared later on in your code. So in line 17 the recordset does not exist yet.

Move the following code to the top (at least earlier than line 17) and it will work

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim adoCon, rscuafc, strSQL, strError, strError1, strError2
  3. %>
  4. <%
  5. Set adoCon = Server.CreateObject("ADODB.Connection")
  6. adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; Dbq=\\Puafo\vaio (d)\puafo\clients\Christchurch United Soccer\cuafc.mdb;"
  7. Set rscuafc = Server.CreateObject("ADODB.Recordset")
  8. %>
  9.  
Apr 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tim Marshall | last post by:
ODBC situation, Access 97, here is the code and I've marked where Access coughs up. The Access error message is 3027, can't update, database is read only. The Oracle table in question has a...
1
by: Jon Trelfa | last post by:
I have been fighting with this script for several days and I'm finally at the end of my rope. Here's the scenario: -I have to add an entry into 1 table, called "calendar" -I must retrieve the...
25
by: dixie | last post by:
I have some code that adds new records into a table for each ID in a list box when a button on a form is clicked. This works fine. My problem now is that I wish to be able to edit all the records...
3
by: jaYPee | last post by:
is there a way to know if the form is edited or not after calling addnew? Me.BindingContext(DsStudentCourse1, "Students").AddNew() because i got an error after closing the form. because in my...
2
by: RS | last post by:
Hello, I need to add a dropdown list to datagrid. Once page is displayed on change of the selection of the dropdown for that row, I need to be able to capture the value of the dropdown and do some...
2
by: pillmill | last post by:
I replaced AddNew statments with INSERT INTO, but am unable to write to the same tables. Foreign keys violations are the main errors. Why are these occuring ? Before: set rs3=...
10
by: fniles | last post by:
In VB6 to add a new record in a recorset, you can use the Addnew method, then set each column's value, then call the Update method. How can I do this in VB.NET ? Thank you. VB6: Private m_rs...
1
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta...
4
by: Paul | last post by:
Hi all, I have a page that has a form on it which has a dropdown list on it. It connect to an sql database and populate the list. What I would like to do is make the list editable so that if the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.