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?
14 1651
what does the code look like in you checkbox?
lee123
Sure, Thank you: - Private Sub chkMon_AfterUpdate()
-
-
If chkMon.Value = -1 Then txtMon.Value = "MO" Else txtMon.Value = Null
-
-
If IsNull(Me.Mon) And Not IsNull(Me.txtMon) Then
-
Response = MsgBox("MONDAY is not an approved day." & vbCrLf & "Do you want to continue?", vbOKCancel + vbExclamation, "Customer Schedule Conflict")
-
End If
-
-
If Response = 2 Then
-
Me.chkMon.Value = 0
-
Me.txtMon.Value = Null
-
ElseIf Response = 1 Then
-
Me.txtOveride.Value = Format(Now(), "mm/dd/yyyy")
-
End If
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 - If chkMon.Value = -1 Then txtMon.Value = "MO" Else txtMon.Value = Null
-
needs to be - If chkMon.Value = -1 Then
-
txtMon.Value = "MO"
-
Else
-
txtMon.Value = Null
-
End If
You can have a single line like - 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)>
Thanks, i tried to re-write the If statement and i am having the same problem.
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)>
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)>
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.
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. - Private Sub chkMon_AfterUpdate()
-
Dim Response As Integer
-
-
If Me.chkMon.Value = -1 Then
-
Me.txtMon.Value = "MO"
-
Else
-
Me.txtMon.Value = Null
-
End If
-
-
If IsNull(Me.Mon) And Not IsNull(Me.txtMon) Then
-
Response = MsgBox("MONDAY is not an approved day." & vbCrLf & "Do you want to continue?", vbOKCancel + vbExclamation, "Customer Schedule Conflict")
-
End If
-
-
If Response = 2 Then
-
Me.chkMon.Value = 0
-
Me.txtMon.Value = Null
-
ElseIf Response = 1 Then
-
Me.txtOveride.Value = Format(Now(), "mm/dd/yyyy")
-
-
End If
-
-
End Sub
-
You've also got some other, non-related issues that I noticed in looking under the hood of your app. First, in this code - Private Sub Form_Load()
-
-
DoCmd.GoToRecord , , acNewRec
-
-
Me.chkSat.Enabled = False
-
Me.chkSun.Enabled = False
-
Me.chkMon.Enabled = False
-
Me.chkTue.Enabled = False
-
Me.chkWed.Enabled = False
-
Me.chkThur.Enabled = False
-
Me.chkFri.Enabled = False
-
-
Me.txtStartDate.Value = Null
-
Me.txtEndDate.Value = Null
-
-
Me.txtStartDate.Visible = False
-
Me.txtEndDate.Visible = False
-
-
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)> 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
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)>
Thanks, really appreciate it.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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;...
|
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...
|
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...
|
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 ...
<%
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
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...
|
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: 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,...
|
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...
|
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...
| |