473,545 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB code in Access 2007 Event Procedure

4 New Member
On my form I have an option box for Band Option and a field box for Band Amount. When I click the Band Option box I want it to fill in the Band Amount field for 500. But it will not work and I cannot figure out why. Here is the code I am using, my option is True/False.

Private Sub Band_Option_Aft erUpdate()
If (Me!Band_Option ) = ["True"] Then
Me!Band_Price = "500"


Else
If (Me!Band_Option ) = ["False"] Then
Me!Band_Price = "0"


End If
End Sub
Sep 25 '10 #1
4 3167
OldBirdman
675 Contributor
Expand|Select|Wrap|Line Numbers
  1. Private Sub Band_Option_Click()
  2. If Me!Band_Option = True Then
  3. Me!Band_Price = 500
  4.  
  5. Else
  6. Me!Band_Price = 0
  7. End If
  8.  
  9. End Sub 
You had one too few 'End If' statements.
'True' is a keyword for boolean (True/False) comparisons.
'If Me!Band_Option = False' not necessary if If Me!Band_Option can only be True or False, and it is not True from 1st test.
Sep 25 '10 #2
mroberts50
4 New Member
Private Sub Band_Option_Cli ck()
If Me!Band_Option = True Then
Me!Band_Price = 500

Else
Me!Band_Price = 0
End If

End Sub

Thanks Birdmand but It still does not fill in the amount field to 500.
Sep 25 '10 #3
OldBirdman
675 Contributor
What does happen, if anything?
Try putting the line
Expand|Select|Wrap|Line Numbers
  1. MsgBox "Amount = " & Me!Band_Price 
before the 'End Sub' statement. That will tell you what is in Band_Price, if anything.
If you don't get a message box after doing the above, then the event isn't being triggered. Go to the properties box of Band_Option and be sure the 'On Click' event has '[Event Procedure]' in it. If not, select it from the choices. Then click the ellipsis (three dots ...) and see if you are taken to the correct code.
Post results of your efforts, what is right, what is wrong.
Sep 25 '10 #4
OldBirdman
675 Contributor
If the above doesn't solve your problems, someone will have to take over this thread. I'm going to be away for a few weeks, often without internet connections, and definitely without the time to continue.
Sep 26 '10 #5

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

Similar topics

2
4490
by: Joseph Macari | last post by:
I recently installed Access 2007; I've been a long time user of access (from ver 1 ). The following code snippet is giving me fits- << Select Case myTide Case 1 Select Case myTideStage Case 1 MsgBox "Tide Stage must be either After Low or Before High" Me! = " "
16
3535
by: google | last post by:
In a continuous form the following code is under a button in the form header. In Access 2003 and earlier, this goes to a new record, then adds relevant data to that new record. DoCmd.GoToRecord , , A_NEWREC If <some codeThen = "CA002" Else
1
2161
by: dvorasnell | last post by:
Hello, I have a fairly simple database. In this dbase, there is a subform which basically holds menu values for the records. These values serve as the "notes" for each record. OK, I find that I am typing a rather long string in many "notes" section of the subform. Rather than have to type this over and over again, I would like to automate...
7
23851
by: preeny8 | last post by:
Hi there, I recently updated to Access 2007, and I'm getting a couple of errors that i'm not sure how to deal with. I worked with a lot of databases in Access 2003 (.mdb), and for some reason some of these databases will not open in access 2007. The errors I get say: "An error occured while loading 'Form_frm_tabstrip'. do you want to...
12
4183
by: pballou | last post by:
The is a simple example of code that worked in access 2003 but does not in access 2007. I have checked it with the debugger and the reason is the value of formField1 does not change in ver. 2007 in the code as the docmd.gotorecord,,acnext moves down the records. But it does in ver 2003. Any Suggestions? Example of Table displayed in a...
5
5868
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of the screen. I have been unable to find any way to disable this button in Access 2007 and subsequently I have been forced to find ways to detect and...
2
1637
by: binui | last post by:
I have a data entry form in which there are two synchronized combo boxes - facility and line. Facility is a read only field and the data comes from a global variable which i had set while the user selects their respective facility button on the main form. Based on the facility, line combo box will be displayed (i wrote the code in the "on current"...
2
2786
by: Bre035 | last post by:
I am attempting to require certain field be populated with data, save the record, and open a new form in one Event procedure when a Comand Button is selected on Form. Unfortunately, this is erroring out on me or halt messages when attempting to run Macro certain intervals. HAlT Message is Condition=True, Action Name=Close, Arguments Form,...
7
4438
Fritz G
by: Fritz G | last post by:
Hi I have a simple one table, one form MS Access 2007 DB. I want to have the data entry person verify their changes to a record before closing the form or moving to the next record only if any changes were made. I copied some VB code from MS KnowledgeBase (Article ID: 197103 ACC2000: How to Prompt User to Save Changes to Record in a Form for...
0
7420
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7934
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...
1
7446
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6003
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...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
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
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
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...

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.