Getting info out of access db..

Results 1 to 3 of 3

Thread: Getting info out of access db..

  1. #1
    Join Date
    Dec 1969

    Default Getting info out of access db..

    Please help..Been stuck on this problem for a week now. I have 2 tables in an access database. The user inputs there postcode (along with other details in an html form) which then accesses the 1st table "POSTCODES" - this then gives me a postcode rating number..This is working fine. From there I store this number in a variable called "strRating". <BR><BR>Right then....I now need to access the 2nd table which has 7 fields - "BEDS", "RATINGAREA0" RATINGAREA1, etc up to RATINGAREA5.(See table below) I need to find the price of the premium using the variable already stored ("strRating" - which gave me the number 0 to 5 from the postcode table) and depending on how many beds are in the house (1 to 5) <BR><BR>So if the user inputs a postcode "ch1", that would give me the rating number "1" (stored in the strRating Variable), how do I then extract the premium from the table below using this variable and assuming they selected 2 beds from the request.form?<BR>(answer to this senario would be £66.25...)<BR><BR>Beds----rating0-rating1-rating2-rating3-rating4-rating5 <BR>---1----43.50---53.00---64.00---78.00---102.50--127.50 <BR>---2----54.38---66.25---80.00---97.50---128.13--159.38 <BR>---3----76.13---92.75---112.00--135.60--179.38--223.13 <BR>---4----91.35---111.30--134.40--163.80--215.25--267.75 <BR>---5----108.75--132.50--160.00--195.00--256.25--418.75 <BR><BR><BR>Any Help please would be greatly appreciated <BR>JJ

  2. #2
    Mike Shaffer Guest

    Default RE: Getting info out of access db..

    Well, there are actually a few ways, but here&#039;s one that is easy to understand when you read the code (self documenting, sorta&#039;):<BR><BR>(assuming that intNumBeds contains the number of beds, strRating is the rating, and tablename is the name of your premiums table)<BR><BR>=======================<BR>strSQL = "Select rating" & strRating & " from tablename where beds=" & intNumBeds<BR><BR>set rs = conn.execute(strSQL)<BR>if rs.eof = False then<BR>&nbsp;&nbsp;&nbsp;response.write "Your premium is " & rs(0)<BR>else<BR>&nbsp;&nbsp;&nbsp;response.write "Could not find!"<BR>end if<BR>rs.close<BR>set rs = nothing<BR>=======================<BR><BR><BR>Hope this helps!<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Getting info out of access db..

    Something like this should work for you, I am assuming that Beds is a numeric data type<BR><BR>Sql=" Select rating" & Right(strRating,1) & " From TableName Where Beds=" & thatvariable & ";"

Posting Permissions

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