473,804 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checkbox problem in an Access 2003 form

4 New Member
I am new to this, I'm assuming the answer is simple for the experienced. I have a checkbox on a form to indicate that a job is a '2ndCoat'. When the user checks the box, I want another field( the 'PriceofJob' field ) to be reduced by 65%. Any help greatly appreciated.
Feb 13 '09 #1
17 2459
NeoPa
32,579 Recognized Expert Moderator MVP
This can be done, but to help it would be easier if we had more info as to which controls are on your form (Names particularly).
Feb 13 '09 #2
TheSealer
4 New Member
I hope this is what you are asking for...The form has the following names/conntrols.
DateOfCall
CallTakenBy
LastName
Address
City
State
Zip
HomePhone
WorkPhone
CellPhone
Fax
EstimatorName
PriceOfJob
2ndCoat (Checkbox)
Feb 13 '09 #3
topher23
234 Recognized Expert New Member
I don't know how to paste code in yet, so I'm just gonna plain-text this.

Put this code into the AfterUpdate event of your 2ndCoat checkbox:

Expand|Select|Wrap|Line Numbers
  1. If Me.2ndCoat then
  2.        Me.PriceOfJob=Me.PriceOfJob * 0.65
  3. Else
  4.        Me.PriceOfJob=Me.PriceOfJob * (1/0.65)
  5. End If
This code allows for the possibility that someone will click 2ndCoat and then realize that they've messed up and click it again to change it back. The code doesn't do anything else that I might recommend, like ensuring that PriceofJob isn't null before trying to perform an operation on it or rounding PriceofJob after the operation.
Feb 13 '09 #4
TheSealer
4 New Member
Thanks - did as sussgested, but the first line of the code (If Me.2ndCoat then)
turns green or red (I'm colorblind) & when I try to run it, I get a the error message: Complie error: Syntax error
Feb 13 '09 #5
OldBirdman
675 Contributor
In the long run, might be better if table had a DiscountRate field, which had a default of 1.00. Me.txtPriceOfJo b would be calculated from that. Checkbox would then change Me.txtDiscountR ate to .65 or if uncheck, then to 1.00.
This would allow for future expansion with other rates, or special promotions. Also, the PriceOfJob would remain, and any discount applied to that.
Feb 13 '09 #6
missinglinq
3,532 Recognized Expert Specialist
The error is caused because Access VBA doesn't like control names that begin with a digit. Because of this, it adds Ctl to the beginning, so the line

If Me.2ndCoat then

should read

If Me.Ctl2ndCoat then


This should do what you need:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Ctl2ndCoat_AfterUpdate()
  2.  
  3. If Not IsNull(Me.PriceOfJob) Then
  4.  
  5.  If Me.Ctl2ndCoat Then
  6.   Me.PriceOfJob = Me.PriceOfJob * 0.65
  7.  Else
  8.   Me.PriceOfJob = Me.PriceOfJob * (1 / 0.65)
  9.  End If
  10.  
  11. Else
  12.  MsgBox "You must first enter a PriceOfJob!"
  13.  Ctl2ndCoat = 0
  14.  PriceOfJob.SetFocus
  15. End If
  16.  
  17. End Sub
Linq ;0)>
Feb 13 '09 #7
NeoPa
32,579 Recognized Expert Moderator MVP
@TheSealer
I can't see why it might. Are you sure the code is EXACTLY as shown?

PS. I would follow the route indicated by OB. Maintain the original value, and have a separate field that holds a multiplier.
Feb 13 '09 #8
NeoPa
32,579 Recognized Expert Moderator MVP
@missinglinq
8-) Didn't realise that Linq.

Lucky you came along.
Feb 13 '09 #9
OldBirdman
675 Contributor
... turns green or red (I'm colorblind) & when I try to run it,
I would suggest that you change the color scheme for VBA to work better for you. If you are only red/green colorblind, there are enough other colors you could use. If needed, combinations with background color might help.
On the Tools menu of the Visual Basic editor, click Tools->Options... and then "Editor Format" tab.
Feb 13 '09 #10

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

Similar topics

1
3508
by: John Mullen | last post by:
I want to take the following HTLM and use javascript to turn on radio buttons if checkbox is checked, can I do this with javascript (maybe onClick or an array) or do i need a server side script ? <li>ABACAVIR SULFATE</li> <INPUT NAME="ingredient0" TYPE=checkbox VALUE="ABACAVIR SULFATE"><br> <input name="ABACAVIR SULFATE AMOUNT" type="radio" value="EQ 300MG BASE">EQ 300MG BASE<br> <input name="ABACAVIR SULFATE AMOUNT" type="radio" value="EQ...
4
4632
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input type="checkbox" name="chk_Complete" value="<%Response.Write l_IsChecked%>"<%if cbool(l_IsChecked) then Response.Write " checked"%>> The code to captures the checkbox value in the asp page that builds the sql string is follows
2
9209
by: /.. | last post by:
Hi all, I'm working on a report display page that currently uses 5 checkboxlists with a total of 86 items to display values from 5 different tables in an Access database. The page works fine now. On presenting it to the users they pointed out that their users could change the values in the checkboxes and then print them out, ultimately documenting false information.
2
11801
by: Thomas R | last post by:
Is is possible? In VS.NET 2003, Binding data to the repeater is easy, but when I try to add an ASP:checkbox to the .aspx page, the designer won't recognize it, hence the code view doesn't allow me to access it. The funny thing is that it compiles fine, and the checkboxes are there, I just can't write to them! Is there a way around this problem? My HTML is as follows:
5
1724
by: sanchs | last post by:
I have created an inventory database in Microsoft Access 2003. In my assets form, I have a checkbox for cannibalized computers. I would like to be able to put a check in that checkbox and have that particular record moved to a new table. Is this possible? If it is possible, can someone please tell me what I need to do to get this to work? Thank you.
6
10427
by: Chuck Anderson | last post by:
My knowledge of JavaScript is limited. I learn from example and then adapt those examples to suit my needs. I have stumped myself on this one. I have a form with checkboxes that I want to group by using a two dimensional array. <form name=msgs>
8
4467
by: Sid | last post by:
I hope someone could help me with this. I am trying to setup a criteria to decide when to allow/not allow user to click on the check box. logically it looks simple but I am not able to incorporate in my data access page. I have a numerical field called tier status and right next to it I have a checkbox. I would like to allow user to check and uncheck the checkbox as long as the tier
18
4051
by: hotflash | last post by:
Hi Mark et All, I understand that you created a very professional document and a similar issue forum out there regarding to Inserting the checkbox value into MS Access using ASP however; I am so new to this stuff and have tried couple times but no luck. Sorry to waste your time again, but would appreciate if you can help me out. I have a form that has a checkbox name of ExpeditedRequest. I can't send the unchecked or checked value to the...
1
1852
by: robboll | last post by:
Access 2003 I have a form (bound to a query) and would like for the user to check a CheckBox to filter records based on a value of one of the fields. If the CheckBox is not checked, it should show all the records. Here is the query criteria I am using: IIf(!!=True,!! ,"*")
11
4418
by: RachH | last post by:
I have an Access 2003 database with a form that is actually a mini-switchboard containing option buttons for various reports, etc. During about 1-2 months of the year, this mini-switchboard is used all the time. The rest of the year, it is not needed at all. I would like to add a checkbox to the mini-switchboard so users can select it to make the mini-switchboard load at startup (in addition to the main switchboard) so it could stay open all the...
0
10600
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10096
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.