Access (Yes/No) selection

Results 1 to 2 of 2

Thread: Access (Yes/No) selection

  1. #1
    Randy Guest

    Default Access (Yes/No) selection

    Hi everyone, I am trying to send data from radio button in a htm and later to access database (by going through some checking mechanism in asp file)<BR>the question is, how do I set access database to accept data sent by a radio button if access database has the data type set to (yes/no). I understand that if an item were to be (yes) then a tick is place on the database itself. So, how do I send a (yes/no/a tick) to a database???<BR>below are some of the coding which I had done on a htm file, asp file and access database<BR><BR>** can I change the value to something else??? like "hideproductlist_yes" or others??<BR><BR>Hide Product List : <BR> &#060;input type="radio" name="hideproductlist" value="yes"&#062;<BR> Yes <BR> &#060;input type="radio" name="hideproductlist" value="no" checked&#062;<BR> No <BR><BR> Active to be sold in market : <BR> &#060;input type="radio" name="activesold" value="yes" checked&#062;<BR> Yes <BR> &#060;input type="radio" name="activesold" value="no"&#062;<BR> No<BR><BR> Hot Deal : <BR> &#060;input type="radio" name="hotdeal" value="yes"&#062;<BR> Yes <BR> &#060;input type="radio" name="hotdeal" value="no" checked&#062;<BR> No <BR><BR><BR>asp file<BR><BR>&#060;%@ Language = VBScript %&#062;<BR><BR>&#060;% Option Explicit %&#062;<BR><BR>&#060;!-- #include virtual="/" --&#062;<BR><BR>&#060;%<BR> &#039Declare variable<BR> Dim productCategory, productTitle, productReferenceNo, productBrand, productDescription, productSellingprice, productCostprice, productStock, productImagefile, productView, productActive, productHotdeal<BR> productCategory = Request.Form("Category")<BR> productTitle = Request.Form("Title")<BR> productReferenceNo = Request.Form("referenceno")<BR> productBrand = Request.Form("brand")<BR> productDescription = Request.Form("description")<BR> productSellingprice = Request.Form("sellingprice")<BR> productCostprice = Request.Form("costprice")<BR> productStock = Request.Form("stock")<BR> productImagefile = Request.Form("imagelocation")<BR> productView = Request.Form("hideproductlist")<BR> productActive = Request.Form("activesold")<BR> productHotdeal = Request.Form("hotdeal")<BR>%&#062;<BR>&#060;%<BR> &#039test to see if values are passed correctly from the registration htm file<BR> Response.Write(productCategory & "<BR>")<BR> response.write(productTitle & "<BR>")<BR> response.write(productReferenceNo & "<BR>")<BR> response.write(productBrand & "<BR>")<BR> response.write(productDescription & "<BR>")<BR> response.write(productSellingprice & "<BR>")<BR> response.write(productCostprice & "<BR>")<BR> response.write(productStock & "<BR>")<BR> response.write(productImagefile & "<BR>")<BR> response.write(productView & "<BR>")<BR> response.write(productActive & "<BR>")<BR> response.write(productHotdeal & "<BR>")<BR>%&#062;<BR>&#060;%<BR> &#039make sure all the data was entered<BR> If ((productCategory = "") OR (productTitle = "") _<BR> OR (productReferenceNo = "") OR (productBrand = "") _<BR> OR (productDescription = "") OR (productSellingprice = "") _ <BR> OR (productCostprice = "") OR (productStock = "") _<BR> OR (productView = "") _<BR> OR (productActive = "") OR (productHotdeal = "")) THEN<BR> <BR> Response.Write("You must enter values for all the fields. Before entering this page")<BR> Response.End<BR> <BR> Else<BR>%&#062;<BR><BR>&#060;%<BR> &#039Call login function and connection<BR> Dim objConn<BR><BR> &#039Create connection with database using DSN-less connection<BR> Set objConn = Server.CreateObject("ADODB.Connection")<BR> objConn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _<BR> "DBQ=C:inetpubwwwrootuser_profile.mdb"<BR> objConn.ConnectionTimeout = 15<BR> objConn.CommandTimeout = 30<BR> objConn.Open <BR> <BR> &#039Execute strSQL<BR> Dim objRS<BR> Set objRS = Server.CreateObject("ADODB.Recordset")<BR> objRS.Open "Product", objConn, , adLockOptimistic, adCmdTable <BR>%&#062;<BR><BR>&#060;%<BR> &#039Declare variable<BR> Dim bolAlreadyExists<BR> bolAlreadyExists = False<BR> <BR> Do While Not (objRS.EOF OR bolAlreadyExists)<BR> if (StrComp (objRS ("ProductName"), productTitle, vbTextCompare) = 0) Then<BR> <BR> Response.Write ("&#060;A Href=&#039add_new_product_login.html&#039&#062;")< BR> Response.Write ("Title already exists.")<BR> response.Write ("&#060;/A&#062;")<BR> bolAlreadyExists = True<BR> <BR> End if<BR> <BR> if (StrComp (objRS ("ProductReferenceNumber"), productReferenceNo, vbTextCompare) = 0) Then<BR> <BR> Response.Write ("&#060;A Href=&#039add_new_product.html&#039&#062;")<BR> Response.Write ("Reference number already exists.")<BR> response.Write ("&#060;/A&#062;")<BR> bolAlreadyExists = True<BR> <BR> End if <BR> <BR> objRS.MoveNext<BR> <BR> Loop<BR> <BR> if NOT bolAlreadyExists Then<BR> <BR> objRS.AddNew<BR> <BR> objRS("Category_ID") = productCategory<BR> objRS("ProductName") = productTitle<BR> objRS("ProductReferenceNumber") = productReferenceNo<BR> objRS("ProductBrand") = productBrand<BR> objRS("ProductDescription") = productDescription<BR> objRS("ProductImage") = productImagefile<BR> objRS("ProductSellingPrice") = productSellingprice <BR> objRS("ProductCostPrice") = productCostprice<BR> objRS("Stock") = productStock<BR> objRS("ProductListHidden") = productView<BR> objRS("ProductActive") = productActive<BR> objRS("ProductHotDeal") = productHotdeal<BR> <BR> objRS.Update<BR> <BR> Response.Write ("Your registration is successful")<BR> <BR> End if<BR> <BR> End if<BR>%&#062;<BR><BR>&#060;%<BR> objRS.Close<BR> set objRS = Nothing<BR> <BR> objConn.Close<BR> set objConn = Nothing<BR>%&#062;<BR><BR>access database<BR>product table<BR><BR>field name data type description<BR>=================================== ===========<BR>Product_ID autonumber<BR>ProductName text<BR>.<BR>.<BR>ProductListHidden (yes/no) <BR>ProductActive (yes/no)<BR>ProductHotDeal (yes/no)<BR><BR>

  2. #2
    Kasper Guest

    Default RE: Access (Yes/No) selection

    Simple..<BR><BR>Although my modus operandi for inserting records is not the OOP one, but rather plain SQL statement!<BR><BR>So you get the value yes/no from the form.request right?<BR>ok, you better have true/false, seeing as that is what you can insert into your sql statement. (don&#039t know about the oop rs.addnew but it should work too)<BR><BR><BR>so example : <BR><BR>objConn.execute "INSERT INTO product (ProductListHidden) VALUES ("&ProductView&");"<BR><BR>conditions : productview should be true or false, and not surrounded by single quotes<BR>(i left out the other fields for speed)<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts