Bo selecta

elgoober

Registered User.
Local time
Today, 19:04
Joined
Mar 2, 2001
Messages
83
Hi

I've got a form based on a table.

2 field on the form - bedtype (PK) and selecta - a check box.

The form is continous.

The idea is that the user selects 1 selection - by ticking the check box. The issue - if they select 1 - I need to ensure that they cannot select any others on the form, and if they do - all the other boxes become unchecked.

I realise that a drop down combo would work better - but the powers that be are insistent on seeing a full list displayed on the form.....

Hope this isn't too rambly

Any light shedding, gratefully appreciated.

Cheers

Paul
 
You could use an option group if there will always be the same choices to choose from. A check box is one of the choices if you pick an option group, and it automatically enforces only picking one choice for you.
 
Use the "on change" event of the check box to trigger an update query to set all other checkboxes to false where they are not equal to this bedtype...
 
Nice

Namliam - nice 1 I like the on change event suggestion, and can see the update working - but my head large and fuzzy - how do I show not equal in the query

Thanks Alisa as well - I don't think? option group app. in this instance

Cheers y'all
 
Thanks Alisa as well - I don't think? option group app. in this instance

An Option Group is really the only choice, assuming you've explained your situation correctly! It only allows one checkbox to be selected at a time!
 
An Option Group is really the only choice, assuming you've explained your situation correctly! It only allows one checkbox to be selected at a time!

He has a table tho, not a limitted set of options, as far as I understand it...
If he has a limited list I would agree... but table doesnt fit... does it?

@Elgoober
How good are you at making queries
Step 1: Make a query to select one particular bedtype
 
How many bedtypes are there actually?
 
Oh

There are about 8 bed's to choose from - on a continous form - with a select box next to each option

They are based on a table with 2 fields
BedType
Selecta

I can hack my way round queries - and have done update in the past - I'm just getting hung up on the criteria for the bedtype

Thanks everyone
 
If he has a checkbox for each item, as he's indicated, and he only wants one to checked at any given time, the Option Group is the only sensible way to go! The fact that his form is based on a table has nothing to do with it, he still has a limited number of checkboxes! Why in the world would you want to write code for each of the eight buttons, to uncheck the other seven buttons, when placing the buttons in an Option Group would do this automatically?
 
misslingling, I am flattered that you so avidly support my suggestion!
 
its no bun fight

hi all

er just to clear this all up - I put an option group onto my form - and it gives me exactly the same conundrum I was in before - i.e you can make multiple choices which I do not wish to do - the user can only select once - which is why the update query makes sense - as if the user selects another choice on the form - all the others are deselected - I guess an option group would work if I listed all 7 choices on a single form - but I think that may limit me for other aspects

cheers for helping me see the light

paul
 
How fixed are your number of beds? If it is a constant (i.e. will not change for 2 years atleast) then an option group surely is an option, except using this with a table... is hard to say the least.

As for the update query... Use = for equal and <> for not equal
 
still here

Hi namliam

I will look again @ option - but I tried that originally - and it has issues with presentation... just for my peace of mind - the update query - I've actioned these before no probs - + understand the <> etc - but I'm massively struggling with - if the user selects 1 item on the list, then changes mind and decides to select another option - @ the moment that gives me 2 yes's effectively - whereas what I want to happen is - as the user selects Yes - all the other options are therefore No - and If the user changes mind and changes one of the No's to Yes - the original Yes turns to No...

So if I do an update query based on Criteria - and say I said <>Yes for the rest of the records to turn to no - but if the user changed mind and selected another Yes - the <>Yes wouldn't apply to the original Yes -(if you see what I mean!!)

This stuff is making my nights despondent - yes I know I should go with that infernal option group - but I'm insanely curious about this other option - and I'm guessing its really simple....

As always - thanks

Paul



As always - nice one - cheers to you all

Use the "on change" event of the check box to trigger an update query to set all other checkboxes to false where they are not equal to this bedtype...
04-03-2008 03:41 PM
 
So if I do an update query based on Criteria - and say I said <>Yes for the rest of the records to turn to no - but if the user changed mind and selected another Yes - the <>Yes wouldn't apply to the original Yes -(if you see what I mean!!)
I see I see, but you dont see what I mean...

You want to select all beds that are not equal to the one the user selected now... So... You update query would set everything to false/No where bedtype <> Currently selected bedtype

This stuff is making my nights despondent - yes I know I should go with that infernal option group - but I'm insanely curious about this other option - and I'm guessing its really simple....

As always - thanks

Paul
Making your nights Despowhat? I am guessing it is something like "nightmares" ?? LOL
 
mist clear - nearly

Perfect translation..

Ok - I see - but I don't - no idea how you put criteria to say current record for bedtype in the update query
 
Me.ColumnName

If you run the query inside the form, Me.ColumnName will return the "current bedtype"

Also it depends a little on if you have an autonumber or some other number as a key value for your table or not.
Presuming you have not (which would probably be a design flaw)
Code:
currentdb.execute "Update table Set Yes/NoField = No where bedtype <> '" & Me.Bedtype & "';"

If you do have some primary key (auto) number
Code:
currentdb.execute "Update table Set Yes/NoField = No where Key <> " & Me.Key
 
But

the bedtype is the primary key of the table - and selecta is the yes/no field - do I use the 1st example with Me.Selecta at end and do I hang this on the OnChange of the selecta control or on 1 of the form events

Don't let the wife know that I communicate more with you....
 
No you want the bedtype at the end.... and the selecta at the Update...

Presuming your field on the form is also called "Bedtype"
Code:
execute "Update table Set Selecta = No where bedtype <> '" & Me.Bedtype & "';"

But yes... you put this in the On change event of the Selecta field.
 
compile

copied and pasted the code onto the OnChange of the selecta

I'm getting a compile error on the BedType (checked spelling - and case) Sub or Function not Defined
 
It is not execute but Currentdb.Execute ""

I made a copy/paste error appearently, also you have to change your "table" name...
 

Users who are viewing this thread

Back
Top Bottom