By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,486 Members | 2,067 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,486 IT Pros & Developers. It's quick & easy.

Storing text from a check box control

kobamfo
P: 14
Hi Guys,
I have a check box named "jobstat" on a form and would like to store a text value in the backend table depending on the value of the "jobstat", so I have this code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub jobstat_AfterUpdate()
  2. Select Case Me![jobstat]
  3.   Case 1
  4.     Me![txtVal] = "Complete"
  5.   Case 0
  6.     Me![txtVal] = "Incomplete"
  7. End Select
the "txtVal" field on the form has its Visibility set to "No" and it is solely responsibly for collecting and committing the text "complete" or "incomplete" to the table.
Now the problem! the "Incomplete" works fine when "jobstat" is unchecked but when checked, the table field which has a data type of Yes/No which is also the Control Source for "txtVal" does not get the "complete" value, Why? What am I doing wrong or not doing?
Nov 9 '12 #1
Share this Question
Share on Google+
2 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
The quick explanation is that the True or Yes in this case is represented as -1, not 1.

I suggest you look a bit at simple debugging. Adding a breakpoint @line 2 for instance, would allow you to check the value of me![jobstat] while hovering the mouse over the variable in the code. That would likely have helped you realise this yourself. Another option is to use Debug.Print or msgbox statements. These are quite usefull as well.
Nov 9 '12 #2

NeoPa
Expert Mod 15k+
P: 31,186
How can that be true?

If a field is of type Yes/No then it is Boolean and is unable to take the String value of "Incomplete", whereas you indicate that it has. Something in what you say must be incorrect, and as such, is impossible to work with.

PS. I should have refreshed before posting. Smiley noticed another problem. The one you were trying to ask about. You should understand that VBA provides terms for True and False such that you can use the code :
Expand|Select|Wrap|Line Numbers
  1. Private Sub jobstat_AfterUpdate()
  2. Select Case Me![jobstat]
  3.   Case True
  4.     'Something that makes sense here
  5.   Case False
  6.     'Something that makes sense here
  7. End Select
Nov 9 '12 #3

Post your reply

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