473,399 Members | 2,774 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,399 software developers and data experts.

Beginner: If Statement Problem

I am new to VB and still have difficulty writing Subs. The following
Sub Automatically updates two Check Boxes, Pass & Resit, in a form
which stores data re Exam Details.

Private Sub Mark_AfterUpdate()

If IsNull(Me.Mark) Then
Me.Pass = False
Me.Resit = False
Else
Me.Pass = (Me.Mark >= 24)
Me.Resit = Not Me.Pass
End If

End Sub

This works fine with exams that have a pass mark of 24 or over.
However There is one module, module 1, which has a pass mark of 27 or
over. The data which records the module number (Module ID) is stored
as a number from 1 to 7.

Will it be possible to ammend the Sub so that it takes this into
account, for instance:

ElseIf
Me.[Module ID] = 1 And Me.Pass = (Me.Mark >=27) Then
Me.Resit = Not Me.Pass

I have tried this with no success. Can you help?
Terry
Nov 12 '05 #1
2 10252
Private Sub Mark_AfterUpdate()
Dim intPassMark As Integer

If Me.[Module ID] = 1 Then
intPassMark = 27
Else
intPassMark = 24
End If

If IsNull(Me.Mark) Then
Me.Pass = False
Me.Resit = False
Else
Me.Pass = (Me.Mark >= intPassMark)
Me.Resit = Not Me.Pass
End If

End Sub
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Terry" <tc*****@merseymail.com> wrote in message
news:38*************************@posting.google.co m...
I am new to VB and still have difficulty writing Subs. The following
Sub Automatically updates two Check Boxes, Pass & Resit, in a form
which stores data re Exam Details.

Private Sub Mark_AfterUpdate()

If IsNull(Me.Mark) Then
Me.Pass = False
Me.Resit = False
Else
Me.Pass = (Me.Mark >= 24)
Me.Resit = Not Me.Pass
End If

End Sub

This works fine with exams that have a pass mark of 24 or over.
However There is one module, module 1, which has a pass mark of 27 or
over. The data which records the module number (Module ID) is stored
as a number from 1 to 7.

Will it be possible to ammend the Sub so that it takes this into
account, for instance:

ElseIf
Me.[Module ID] = 1 And Me.Pass = (Me.Mark >=27) Then
Me.Resit = Not Me.Pass

I have tried this with no success. Can you help?
Terry

Nov 12 '05 #2
Thanks for your help Allen......Works like a dream!
Terry

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<3f**********************@freenews.iinet.net. au>...
Private Sub Mark_AfterUpdate()
Dim intPassMark As Integer

If Me.[Module ID] = 1 Then
intPassMark = 27
Else
intPassMark = 24
End If

If IsNull(Me.Mark) Then
Me.Pass = False
Me.Resit = False
Else
Me.Pass = (Me.Mark >= intPassMark)
Me.Resit = Not Me.Pass
End If

End Sub
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Terry" <tc*****@merseymail.com> wrote in message
news:38*************************@posting.google.co m...
I am new to VB and still have difficulty writing Subs. The following
Sub Automatically updates two Check Boxes, Pass & Resit, in a form
which stores data re Exam Details.

Private Sub Mark_AfterUpdate()

If IsNull(Me.Mark) Then
Me.Pass = False
Me.Resit = False
Else
Me.Pass = (Me.Mark >= 24)
Me.Resit = Not Me.Pass
End If

End Sub

This works fine with exams that have a pass mark of 24 or over.
However There is one module, module 1, which has a pass mark of 27 or
over. The data which records the module number (Module ID) is stored
as a number from 1 to 7.

Will it be possible to ammend the Sub so that it takes this into
account, for instance:

ElseIf
Me.[Module ID] = 1 And Me.Pass = (Me.Mark >=27) Then
Me.Resit = Not Me.Pass

I have tried this with no success. Can you help?
Terry

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: The Tao of Spike | last post by:
I've recentlty been getting into programming. I was wondering what language to learn first and after asking around I decided on Python. I'm about half way through "Non-Programmers Tutorial For...
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
8
by: Foxy Kav | last post by:
Hi everyone, Im currently doing first year UNI, taking a programming course in C++, for one project i have to create a simple array manipulator... that i have done, but i cant figure out how to...
8
by: Bshealey786 | last post by:
Okay im doing my final project for my first computer science class(its my major, so it will be my first of many), but anyway im a beginner so im not to great with C++ yet. Anyway this is the error...
12
by: Blaze | last post by:
I am doing the first walk through on the Visual Studio .Net walkthrough book to learn a little about programming. I am having issues with the first tutorial not running correctly. It seems that...
1
by: c_beginner | last post by:
yes, this is my how work question. Since I am lack in getting an assistance with my lab work I put this in this advance group. Sorry for the trouble I am making. Write a program to calculate the...
6
by: RJ | last post by:
I'm trying to teach myself Python (probably running into the old dog new tricks issue) and I'm trying to start with the very basics to get a handle on them. I'm trying to write code to get the...
2
by: mark39 | last post by:
I'm trying to find a way to create a simple 'targeted ads' function on my page. When a user makes a selection from a dropdown list, I would like to use an onClick function to load an html file with...
4
by: subramanian100in | last post by:
In the book, C++ Coding Standards book by Hereb Sutter and Andrei Alexandrescu, in Item 40 on pages 86-87 viz, "Avoid providing implicit conversions", the authors have advised the use of named...
22
by: ddg_linux | last post by:
I have been reading about and doing a lot of php code examples from books but now I find myself wanting to do something practical with some of the skills that I have learned. I am a beginner php...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
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,...

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.