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

VB code in Access 2007 Event Procedure

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_AfterUpdate()
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 3161
OldBirdman
675 512MB
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
Private Sub Band_Option_Click()
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 512MB
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 512MB
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
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...
16
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...
1
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...
7
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...
12
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...
5
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...
2
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...
2
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...
7
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.