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

Checkbox problem

I have amessage box that is used when a user clicks on a checkbox. if the user hits cancel, all of the other checkboxes dont work (when i click them, nothing happens) but if the user hits ok instaed, everything works fine. Any ideas?
Dec 11 '07 #1
14 1651
lee123
556 512MB
what does the code look like in you checkbox?

lee123
Dec 11 '07 #2
Sure, Thank you:
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkMon_AfterUpdate()
  2.  
  3.     If chkMon.Value = -1 Then txtMon.Value = "MO" Else txtMon.Value = Null
  4.  
  5.     If IsNull(Me.Mon) And Not IsNull(Me.txtMon) Then
  6.         Response = MsgBox("MONDAY is not an approved day." & vbCrLf & "Do you want to continue?", vbOKCancel + vbExclamation, "Customer Schedule Conflict")
  7.     End If
  8.  
  9.     If Response = 2 Then
  10.         Me.chkMon.Value = 0
  11.         Me.txtMon.Value = Null
  12.     ElseIf Response = 1 Then
  13.         Me.txtOveride.Value = Format(Now(), "mm/dd/yyyy")
  14.     End If
Dec 11 '07 #3
missinglinq
3,532 Expert 2GB
You don't show the entire Sub procedure, but the code you do show has unmatched If...End Ifs. You may have another End If you didn't show, and hence have matching If...End Ifs, but I think they're in the wrong places. This line

Expand|Select|Wrap|Line Numbers
  1. If chkMon.Value = -1 Then txtMon.Value = "MO" Else txtMon.Value = Null
  2.  
needs to be

Expand|Select|Wrap|Line Numbers
  1. If chkMon.Value = -1 Then 
  2.    txtMon.Value = "MO"
  3. Else
  4. txtMon.Value = Null
  5. End If
You can have a single line like
Expand|Select|Wrap|Line Numbers
  1. If chkMon.Value = -1 Then txtMon.Value = "MO" 
without a closing End If, but not an If...Else... on a single line without and End If.

Mismatched If...End Ifs cause many strange things, so try correcting this and see what happens.

Linq ;0)>
Dec 11 '07 #4
Thanks, i tried to re-write the If statement and i am having the same problem.
Dec 12 '07 #5
missinglinq
3,532 Expert 2GB
Don't know what to tell you. The change I suggested needed to be done, but I was afraid it wouldn't solve things. The problem is that none of the code you've posted has anything to do with any checkboxes other than thechkMon. I guess we need to be able to actually look under the hood of your database, if you could zip it up and post it here.

BTW, what is the object Me.Mon referring to in

If IsNull(Me.Mon) And Not IsNull(Me.txtMon) Then

Linq ;0)>
Dec 12 '07 #6
This is killing me. I couldnt attach a file, it was too big so the link to the file is below. if you could take a look at it i would really appreciate it.

http://www.imperialelevatorcorp.com/...d/checkbox.zip
Dec 12 '07 #7
missinglinq
3,532 Expert 2GB
I'll have to look at this in depth later today when I get some time, and try to figure out exactly what you're trying to do.

Right off hand I see one problem in that your Time Period Option Group isn't bound to your underlying table. This means if you enter a new patient, select, say, Permanent and pick the desired days, then go to another record and come back to the new patient to change days, you've got to select Permanent again to enable your check boxes. When you return to an existing record, the checkboxes should be enabled/disabled depending on the value in the Option Group; you shouldn't have to go thru the process again and this requires that the Time Period select be a part of each record.

What I can't reproduce is the problem you've stated! If I enter a new record, click on Permanent or Multiple Days, select chkMon, the messagebox comes up and I hit Cancel, the checkboxes are still enabled! Is there anything you can add to help me figure out what's going wrong for you? Maybe give me a step by step of what you're doing that's leading up to the problem?

Linq ;0)>
Dec 12 '07 #8
Thank you again.When i pull up the first recor "Leon Lantsman" and select either "permanent" or "multiple days" and select SAT, after hitting cancel, all the checkboxes are enabled but i cant check off su, mon, tue, wed, thur, fri. i have tried on other machines, and i get the same problem.
Dec 12 '07 #9
missinglinq
3,532 Expert 2GB
I've got to tell you this thing has been driving me crazy! I actually dreamnt about it last night and woke up this morning with the answer! I really don't even understand why this was causing the particular problem, but it solves it!

At the top of your code module you have this statement

Option Explicit

From Access Help:
"When Option Explicit appears in a module, you must explicitly declare all variables using the Dim, Private, Public, ReDim, or Static statements."

The problem is that you didn't do this for the variable (Response) that you use to hold the user's choice from your messagebox! You need to redo the AfterUpdates for all of your checkboxes to add this single line:

Dim Response As Integer


at the beginning of each sub, as it appears here in Line # 2.
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkMon_AfterUpdate()
  2. Dim Response As Integer
  3.  
  4.     If Me.chkMon.Value = -1 Then
  5.         Me.txtMon.Value = "MO"
  6.     Else
  7.         Me.txtMon.Value = Null
  8.     End If
  9.  
  10.     If IsNull(Me.Mon) And Not IsNull(Me.txtMon) Then
  11. Response = MsgBox("MONDAY is not an approved day." & vbCrLf & "Do you want to continue?", vbOKCancel + vbExclamation, "Customer Schedule Conflict")
  12.     End If
  13.  
  14.     If Response = 2 Then
  15.         Me.chkMon.Value = 0
  16.         Me.txtMon.Value = Null
  17.     ElseIf Response = 1 Then
  18.         Me.txtOveride.Value = Format(Now(), "mm/dd/yyyy")
  19.  
  20.     End If
  21.  
  22. End Sub
  23.  
You've also got some other, non-related issues that I noticed in looking under the hood of your app. First, in this code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.     DoCmd.GoToRecord , , acNewRec
  4.  
  5. Me.chkSat.Enabled = False
  6. Me.chkSun.Enabled = False
  7. Me.chkMon.Enabled = False
  8. Me.chkTue.Enabled = False
  9. Me.chkWed.Enabled = False
  10. Me.chkThur.Enabled = False
  11. Me.chkFri.Enabled = False
  12.  
  13.     Me.txtStartDate.Value = Null
  14.     Me.txtEndDate.Value = Null
  15.  
  16.     Me.txtStartDate.Visible = False
  17.     Me.txtEndDate.Visible = False
  18.  
  19. End Sub
why do you have all the checkboxes disabled here when you already have them disabled in the Properties Box in Design View? I don't think it it really causes any problems to disable them twice, but I'm concerned that you may think it's doing something here that it's not!

And secondly, go to your dropdown box, select Sara Lantsman, and see whose record pops up!

After you get your code modified to include the

Dim Response As Integer

statement and make sure this is performing as you wanted, post back and we'll address the other issues.

Linq ;0)>
Dec 13 '07 #10
NeoPa
32,556 Expert Mod 16PB
With all those nubile (and semi-dressed) pop-stars and actresses to dream of - you dream of a database!
You neeeeed help my friend :D
Dec 13 '07 #11
missinglinq
3,532 Expert 2GB
Sad but true, Ade! Actually, I've dreamed code since I first started writing it, years ago in Basic! Some of my best hacks came to me that way, including how to program a relational database in Basic! Of course, I didn't actually know that it was a relational database; this was back before Access and DB5 and such were invented! I just knew it kept me from entering the same data over and over again!

Linq ;0)>
Dec 13 '07 #12
missinglinq
3,532 Expert 2GB
darnnnel, since we've solved your original problem, I'm going to split off the new problem into a separate thread located at Combobox always retrieves the first client when multiple clients have same last name. It's a problem that comes up from time to time, and this way we can give it a more descriptive name which may help others that come searching!

Linq ;0)>
Dec 13 '07 #13
Thanks, really appreciate it.
Dec 13 '07 #14
NeoPa
32,556 Expert Mod 16PB
Sad but true, Ade! Actually, I've dreamed code since I first started writing it, years ago in Basic! Some of my best hacks came to me that way, including how to program a relational database in Basic! Of course, I didn't actually know that it was a relational database; this was back before Access and DB5 and such were invented! I just knew it kept me from entering the same data over and over again!

Linq ;0)>
It's called inspiration. Where would we be without it.
Dec 13 '07 #15

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

Similar topics

1
by: Claire | last post by:
Hello, I am having a problem in my struts application with the checkboxes in my form. I have an array of checkboxes, some of which may be already selected when the form loads. My problem is when...
2
by: Tomas Vera | last post by:
Hello All, I'm having problems creating a page with dynamic checkboxes in a WebApp. In my app, I need to query a database, then (based on results) add checkboxes to my form and set their...
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
10
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox...
4
by: SJ | last post by:
Hi all, I have come across a weird problem when attempting to automatically set the focus in a vb.net form to a checkbox control... In my form I have (on a tab page in a tab control) several...
1
by: spolsky | last post by:
try the the following code with Opera 9.01 (Windows). when clicked slightly faster than normal clicking, the toggler checkbox and other checkboxes displays differently although event method works...
9
by: morellik | last post by:
Dear all, I have a program that creates dinamically a web page. In the page I have the following function to check how many checkbox are checked. function tarInfo(info) { var i=0; var c=0;...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
3
by: Mahathi | last post by:
Hi I have a small problem in maintaining the state of a check box. Please do me a favour by telling me the procedure how to do that. My requirement is that "I have to map some roles with...
4
by: Charlotte | last post by:
Hi, I have a problem with a ASP-script, can somewone help me ? here is what I've got: mypage.asp : .... code ... <%
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...
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.