473,385 Members | 1,907 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,385 software developers and data experts.

Continuous form - control behaviour

6
Hi all,

I have a continuous form (not a subform) with a label, text box and two toggle buttons. When I click the toggle button for a record, that toggle button changes on ALL the records in the form. Web searches indicate that unbound controls on a continuous form are all the same instance of one control, but this button is bound to a field in the query.

How do i get only the toggle button that I press to change?


A2k3:WinXP
Oct 6 '09 #1

✓ answered by NeoPa

@mcalex
The semi-colons separate the three possibilities :
Positive number; Zero; Negative number
As the value False resolves to zero and True to -1, these are the only two required when you can be sure you are only ever dealing with the two boolean values True & False. To be safe though, I always handle numeric values <>-1 as well. Any non-zero value is treated as True, although only -1 is actually =True. The colour is a bonus. Sounds like you have implemented this pretty well really :)
@mcalex
Nicely thought out - and no this can stay here as it's all relevant.

Null is not a numeric value at all. That is the long and the short of it. Null formatted as anything stays as a simple Null I'm afraid. That is to say it cannot be handled by formatting.

However, all is not lost. If you know how you would like the Null to be treated it is possible, using Nz(), to treat Null values as something else in your query. This can then trigger the relevant formatting.

EG. Say you wanted it treated as False, then you could make the source for the field Nz([tglElected],0). If you wanted it to stand out from the existing True/False values then you could set it to 1 (Nz([tglElected],1)) and format it as Null;False;True, as the positive position is not otherwise used for boolean values.

10 3694
missinglinq
3,532 Expert 2GB
First to do would be to doublecheck that it actually bound as you think. What field is in the Control Source? What kind of field is it bound to? Needs to be a Yes/No field.

Welcome to Bytes!

Linq ;0)>
Oct 6 '09 #2
NeoPa
32,556 Expert Mod 16PB
As Linq has already indicated (very diplomatically of course) it sounds like the control is not actually bound.

Please confirm what you find so that we know you're all ok now.
Oct 6 '09 #3
mcalex
6
G'day Linq, NeoPa

thanks for replies, i'm gmt+8, so i'll double check when I get in to work tomorrow, and report. In the interim ...

Yes, I'm pretty sure the control is bound. The field is IsElected (it's a council elections db) and is Yes/No. My surety here stems from the fact I've taken the control source out and put it back in - at least i think i put it back in, now i'm doubting myself :) - to check i didn't do anything stupid. Interestingly, it seems that only the record that I click the toggle button on is changed in the database, so it's a view rather than a model problem, but I digress.

One thing I think i've done wrong (i only thought of this on the train going home) is that i've changed the query (and the underlying table) in the misbehaving form, from the original that I was using and which is used by the form that calls the problem form. Both queries use the same ID field to retrieve their data, so this may(?) explain it behaving in this manner. That rationalisation _should_ let the hindbrain get some rest tonight :-)

As promised will report back in the am (um maybe your late pm linq, otherwise tomorrow for you and NeoPa) about the boundedness, and whether changing the calling form's query to match this has any effect.

cheers
mcalex

diplomacy: lol, i've seen some of the newb postings here and fully understand
Oct 6 '09 #4
NeoPa
32,556 Expert Mod 16PB
Let's see what tomorrow brings. I can't think of another explanation for that behaviour, but we can focus more precisely when we know the full story.
Oct 6 '09 #5
Deezel
6
I am a newbie, but I also have a continous form with four check/toggle boxes. All are set to Yes/No in the table and I clicked on the Code view to see what I had and this is what was there:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Form_Load()
  4.  
  5. End Sub
  6.  
  7. Private Sub Handicap_Retro_Click()
  8.  
  9. End Sub
  10.  
  11. Private Sub Other_Click()
  12.  
  13. End Sub
  14.  
  15. Private Sub ReRent_Click()
  16.  
  17. End Sub
  18.  
  19. Private Sub Start_Up_Click()
  20.  
  21. End Sub
Maybe you're just over thinking it or there's a glitch in your form and you need to redo it. Good Luck.
Oct 6 '09 #6
Deezel
6
Oh and None of the toggle boxes are required or indexed.
Oct 6 '09 #7
mcalex
6
OK:

Yes, the ToggleButton is bound to a Yes/No field. And I did need to fix the underlying query, but that wasn't the problem

However, Deezel has pointed me towards the reason. My toggle button has 'on' and 'off' pictures (basically a red or green rectangle with No or Yes text in the middle), and I would like the button to have the correct picture depending on its state. Therefore, I am responding to the _AfterUpdate() event with a simple if (tglElected) then .Picture = "c:\path\yes.bmp"

When i comment the code in the event, the buttons work on a per record basis. When the code is there - bam! clicking one button changes them all. So it works behind the scenes, but once the button is explicitly referenced the magic is broken?

I guess that means the question is now: How do I get a custom picture (or even switch the caption between 'Yes' and 'No') on a toggle button depending on its state in a continuous form

thanks everyone
Oct 7 '09 #8
NeoPa
32,556 Expert Mod 16PB
The only thing stored in a bound control is the value. Any changes to anything else will be global as you are changing the control and not the data behind it (See Why Values in Unbound Form Controls do not Persist). For that reason a Caption cannot be used for this.

A TextBox may be required to hold this value as a CheckBox has no facility for displaying the data as other than a tick that I could find.

You would have to format the Boolean value as True;False;True and add the Click functionality to toggle the value in an event procedure.
Oct 7 '09 #9
mcalex
6
g'day again NeoPa

Thanks for the textbox solution. Worked it just like you said, except I'm not sure of the 'True' before the first semicolon in your format (mine starts with the semicolon) and I added [<Colour>] after the quotes in each format section. I now have a much more visual effect than the toggle button being depressed in a continuous form - which has been the main aim of this exercise. :-)

Now, for your next trick - how do I do that with a triple-state field?

It's virtually the same situation as the now-solved 'IsElected' issue, except nulls are allowed. It doesn't look like Yes/No formats include a third option even though there are three sections to the format code.

Apologies if this question warrants a separate thread. I can't intuitively tell if it's a simple change to your text box idea, or a hack requiring a conversion of the boolean to a numeric value greater than, less than or equal to zero - but it's looking like the latter :-}
Oct 8 '09 #10
NeoPa
32,556 Expert Mod 16PB
@mcalex
The semi-colons separate the three possibilities :
Positive number; Zero; Negative number
As the value False resolves to zero and True to -1, these are the only two required when you can be sure you are only ever dealing with the two boolean values True & False. To be safe though, I always handle numeric values <>-1 as well. Any non-zero value is treated as True, although only -1 is actually =True. The colour is a bonus. Sounds like you have implemented this pretty well really :)
@mcalex
Nicely thought out - and no this can stay here as it's all relevant.

Null is not a numeric value at all. That is the long and the short of it. Null formatted as anything stays as a simple Null I'm afraid. That is to say it cannot be handled by formatting.

However, all is not lost. If you know how you would like the Null to be treated it is possible, using Nz(), to treat Null values as something else in your query. This can then trigger the relevant formatting.

EG. Say you wanted it treated as False, then you could make the source for the field Nz([tglElected],0). If you wanted it to stand out from the existing True/False values then you could set it to 1 (Nz([tglElected],1)) and format it as Null;False;True, as the positive position is not otherwise used for boolean values.
Oct 8 '09 #11

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

Similar topics

3
by: Prakash Wadhwani | last post by:
Is there any EASY way to highlight a full row in a continuous form so that as i navigate up & down the table/continuous form using the arrow keys, the entire line (all fields) get highlighted ? ...
3
by: Benjamin Z. Gregorian | last post by:
Hi there I have a problem with a database I wrote. On my access 2002 it is running without probs but on the comp of my collegue A2003 there is this weird behaviour. The form is a continuous...
3
by: Mark | last post by:
Hi there, I have a subform, set as a continuous form. When a user selects a particular record in that subform, how can I make that particular record stand out (color or font change, size, etc) from...
3
by: Richard Hollenbeck | last post by:
I have the following query in my form's code: Private Function Get_Data(fieldNum As Integer) Dim strSQL As String Dim db As DAO.Database Dim rs As DAO.Recordset strSQL = "SELECT & "", "" & ...
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
14
by: Mark | last post by:
How can the instances of a textbox control on an continuous form be addressd? Can a specific instance be addressed? For example, a continuous form has ten records. How can the textbox for the...
3
by: DavidB | last post by:
I have a Snapshot Control in a continuous form and I want the source for the control to be different for each instance of the continuous data (based on one of the fields in the recrod source for...
0
by: Jeremy Wallace | last post by:
Folks, Here's a write-up I did for our developer wiki. I don't know if the whole rest of the world has already figured out how to do this, but I hadn't ever seen it implemented, and had spent a...
2
by: Steve | last post by:
I have a continuous form showing Product Code and Product Name. Product Code is five digits and is sequential. I have a textbox in the form header. What is the code to scroll the continuous form so...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.