Closed Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 22

Thread: combo maker

  1. #1
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    combo maker

    Hi All,

    I'm trying to use the code from samples for dynamic combo maker but having a small issue.

    I'm only getting one drop down list and it doesn't have any data in it....

    can you see what I'm missing?

    Code:
    sub comboMaker(varSQL, varID, varField, varSelected)	
    ' This sub creates a generic combo box with values from a table
    	set rsDD = GetRS(varSQL)
    	set obj = nothing
    	do while not rsDD.eof
    		response.Write("<option value=""" & rsDD(varID) & """")
    		if varSelected <> "" then
    			if cstr(rsDD(varID)) = cstr(varSelected) then
    				response.Write(" selected ")
    			end if
    		end if 
    		response.Write(">" & rsDD(varField) & "</option>" & vbCrLf)
    		rsDD.MoveNext
    	loop
    end sub
    
    this is what i have:
    Code:
    <tr>
    <td><%
    strSQL = "SELECT RegionID, RegionName FROM vwReg_Dist ORDER BY RegionName"
    response.Write("<select name=""MyRegName"">" & vbCrLf)
    response.Write(vbTab & "<option value="""">Select ....</option>" & vbCrLf)
    Call comboMaker(strSQL, RegionID, RegionName, request("MyRegName"))
    response.Write("</select>")
    %>
    </td>
    </tr>
    
    I'd like to try to use this because I don't want to have to reload my page.


  2. #2
    Barn Frequenter icoombs will become famous soon enough icoombs's Avatar
    Join Date
    Jul 2008
    Location
    Hayes, Middlesex, UK
    Posts
    151
    Real Name
    Ian Coombs
    Rep Power
    4

    Looks like you might need to add quotes around some of the parameters your passing to the function...

    Code:
    Call comboMaker(strSQL, "RegionID", "RegionName", "request(""MyRegName"")")
    
    Not sure about the last one but give it a try.

  3. #3
    Barn Frequenter BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche's Avatar
    Join Date
    Mar 2008
    Posts
    188
    Rep Power
    5

    Yep, icoombs is exactly right. You are passing values not variables. Also, I cleaned it up a bit. Use if you like:

    Code:
    Sub ComboMaker(strSQL, strSelectName, intID, strField, strSelected)
    	' -- Create Recordset --
    	Set rsDD = GetRS(strSQL)
    
    
    	' -- Create Select --
    	response.write "<select name=""" & strSelectName & """>" & vbCrLf
    	response.write "<option value="""">Select</option>" & vbCrLf
    
    
    	' -- Add Options --
    	If Not rsDD.EOF Then
    		Do While Not rsDD.EOF
    			response.write "<option value=""" & rsDD(intID) & """"
    			If CStr(rsDD(intID)) = CStr(strSelected) Then
    				response.write " selected"
    			End If
    			response.write ">" & rsDD(strField) & "</option>" & vbCrLf
    		rsDD.MoveNext
    		Loop
    	End If
    
    	' -- Close Select --
    	response.write "</select>"
    
    
    	' -- Close Connection --
    	rsDD.Close
    	Set rsDD = Nothing
    End Sub
    
    To call:

    Code:
    strSQL = "SELECT RegionID, RegionName FROM vwReg_Dist ORDER BY RegionName"
    Call ComboMaker(strSQL, "MyRegName", "RegionID", "RegionName", Request("MyRegName"))
    
    "You'll never be as perfect as BLaaaaaaaaarche."

  4. #4
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    Thanks Peeps....I still must be doing something wrong...still only getting the Select .... in the dropdown.

    I'll keep trying.....and check back.

  5. #5
    Barn Frequenter BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche's Avatar
    Join Date
    Mar 2008
    Posts
    188
    Rep Power
    5

    View the source and paste the output for us...
    "You'll never be as perfect as BLaaaaaaaaarche."

  6. #6
    Barn Frequenter BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche's Avatar
    Join Date
    Mar 2008
    Posts
    188
    Rep Power
    5

    Also, do you have GetRS() defined anywhere as a function? You are calling this in the ComboMaker() function.

    Why is this line included in the sub:

    Code:
    set obj = nothing
    
    "You'll never be as perfect as BLaaaaaaaaarche."

  7. #7
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    Hiya B,

    no i don't think i have getRS defined.

    output shows this error:

    Code:
    <font face="Arial" size=2>
    <p>Microsoft VBScript runtime </font> <font face="Arial" size=2>error '800a000d'</font>
    <p>
    <font face="Arial" size=2>Type mismatch: 'GetRS'</font>
    <p>
    
    not sure about the line in above post, i just used it becuz it was in the code sample.

  8. #8
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    GetRS is a seperate function that you can find in the codebank as well. you can forget the set obj = nothing. my mistake ... that was used in an intranet application as we were using a com object for connection string.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  9. #9
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    Thanks Peeps,
    making some progress...
    this is the source output now...but on my screen i have the dropdown list with only Select .... still....all region names are not in a list its just output ....no errors that i can see but not like i expected either.

    Code:
    <tr>
    <td><select name="MyRegName">
    	<option value="">Select ....</option>
    <select name="MyRegName">
    <option value="">Select</option>
    <option value="1">Africa</option>
    <option value="1">Africa</option>
    <option value="1">Africa</option>
    <option value="1">Africa</option>
    <option value="1">Africa</option>
    <option value="1">Africa</option>
    <option value="1">Africa</option>
    <option value="1">Africa</option>
    <option value="2">Asia Pacific</option>
    <option value="2">Asia Pacific</option>
    <option value="2">Asia Pacific</option>
    <option value="2">Asia Pacific</option>
    <option value="2">Asia Pacific</option>
    <option value="2">Asia Pacific</option>
    <option value="2">Asia Pacific</option>
    <option value="3">Eurasia</option>
    <option value="3">Eurasia</option>
    <option value="3">Eurasia</option>
    <option value="3">Eurasia</option>
    <option value="3">Eurasia</option>
    <option value="3">Eurasia</option>
    <option value="3">Eurasia</option>
    <option value="3">Eurasia</option>
    <option value="3">Eurasia</option>
    <option value="6">Latin America</option>
    <option value="6">Latin America</option>
    <option value="6">Latin America</option>
    </select></select>
    </td>
    </tr>
    

  10. #10
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    i think it's because you have 2 selects in there. show the code you're currently using. also, you may want to change your select statement to DISTINCT so that you don't get repeated values.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

Closed Thread
Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. Adding ALL Button to Combo Box
    By Northernlion in forum Microsoft Access
    Replies: 3
    Last Post: July 8th, 2008, 02:03 PM
  2. Combo Box - Add Entry Not In List
    By AOG123 in forum Access Database Samples
    Replies: 0
    Last Post: June 6th, 2008, 10:35 AM
  3. Quick Links - Combo Open Forms
    By AOG123 in forum Access Database Samples
    Replies: 0
    Last Post: June 4th, 2008, 09:46 AM
  4. Dynamic Combo Maker
    By mehere in forum ASP Code Samples
    Replies: 0
    Last Post: March 28th, 2008, 10:40 AM

Bookmarks

Posting Permissions

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

SEO by vBSEO