473,651 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Edit conditional statements in vba via form.

14 New Member
Hi i have this code:
i want to make it available for user to change/edit the values i.e(marks range and grade) in a form. is it possible?

Expand|Select|Wrap|Line Numbers
  1. Public Function ValGrade(PrMark As Double) As String
  2. Select Case PrMark
  3. Case 80 To 100
  4. ValGrade = "A"
  5. Case 75 To 80
  6. ValGrade = "A-"
  7. Case 70 To 74
  8. ValGrade = "B+"
  9. Case 65 To 69
  10. ValGrade = "B"
  11. Case 60 To 64
  12. ValGrade = "B-"
  13. Case 55 To 59
  14. ValGrade = "C+"
  15. Case 50 To 54
  16. ValGrade = "C"
  17. Case 45 To 49
  18. ValGrade = "C-"
  19. Case 40 To 44
  20. ValGrade = "D+"
  21. Case 35 To 39
  22. ValGrade = "D"
  23. Case 30 To 34
  24. ValGrade = "D-"
  25. Case Else
  26. ValGrade = "E"
  27. End Select
  28. End Function

Attached Images
File Type: jpg final.jpg (37.3 KB, 328 views)
Sep 3 '13 #1
5 1231
jimatqsi
1,276 Recognized Expert Top Contributor
What you are asking for is very basic forms development. I think the best advice anyone can give you for now is to go to Help and look at the database sample(s) with your version of Access.You will find very good demonstrations of how to program in Access. Once you work through 1 or 2 examples in the sample db you will know how to do what you are asking about, or you'll be able to frame a more definitive question that we can answer here.

You will be surprised at how simple it quickly becomes for you.

Jim
Sep 3 '13 #2
sashasandy
14 New Member
thanks, surprisingly i have found the solution!!
by using lookup in a simple query.
Sep 3 '13 #3
jimatqsi
1,276 Recognized Expert Top Contributor
Well, I don't see how lookup relates to editing values, but the important thing is you're learning how to solve problems by your own means. As you get experience it won't be so surprising. :)

We're here when you need help.

Jim
Sep 3 '13 #4
sashasandy
14 New Member
hehe!! i guess it has had u in surprise also, because it does!
i used a query instead of vba.
see attachment below for any one who might bump into this.
this Thread is SOLVED!
:-)
Attached Files
File Type: zip Grade.Awarding.zip (25.0 KB, 75 views)
Sep 3 '13 #5
zmbd
5,501 Recognized Expert Moderator Expert
Sashasandy:
You are not editing values in the list of the lookup control. This is what you asked for - not what you actually needed, and to confuse matters more, the posted code acts as a red-herring sending us off on some other tangent.

Instead of what you asked and posted code for, what it appears that you needed was to be able to change the value stored in field [Comments]![comment] while limiting it to a known set of values.

If you had clearly asked this question to begin with, we would have had you to that lookup field within a post or two.

BTW: Sashasandy, this is basically the same question you asked in your last thread. How to Customize an IF Function in vba using a form. Although I am flattered that you used the "Select...C ase" construct, I would still suggest looking at Seth's solution using the table and ranges. In fact, using the lookup field you can base the values on a table, once again, making it easier to maintain.

jimatqsi:
As I'm sure you've realized by now, what Sashasandy was asking for was a way to change the value in the field [Comments]![comment] using a standard set of values. Replacing the text more than likely with a numeric.

In anycase, what Sashasandy solution is simply, as jimatqsi well knows, a simple lookup-field... one of the more common tools that we use in queries and forms.
Sep 3 '13 #6

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

Similar topics

15
2265
by: Max | last post by:
Hi, I'm a perl programmer and am trying to learn PHP. So far I have figured out most of the differences, but have not been able to find out how to do the following: When running through a loop, how can you test two separate conditions against the same $element of an array. For example, this is how I thought it would be done (similar to Perl), but it did not work:
3
3879
by: Patrice | last post by:
Hi, I need to do multi-conditional statements like below, but this error is displayed : Expected 'End' /myFilepath, line x else response.write(arrCorpo(sparam,sdiv)) end if I don't understand why this 'Expected 'End'' error is called! Here is my code: <%
3
1605
by: Sergej Andrejev | last post by:
Not long ago I was asked to give PHP lections to some private IT school. I'm on second lection now, and will be teaching my :) students conditional statements (if..else and switch) and loops (while and for). That was my story, now the question. Can you give me an advise on some geeky use of those statements to stir up some enthusiasm in students. Thanks in advance
92
9842
by: Raghavendra R A V, CSS India | last post by:
hie.. Do any one knows how to write a C program without using the conditional statements if, for, while, do, switch, goto and even condotional statements ? It would be a great help for me if someone helps me... Urgent - Please reply soon ! Thanks, Raghu
2
1439
by: prasad | last post by:
hai all users i resquesting the conditional statements examples. thaniking you inagaprasdreddy
9
1785
by: horizon5 | last post by:
Hi, my collegues and I recently held a coding style review. All of the code we produced is used in house on a commerical project. One of the minor issues I raised was the common idiom of specifing: <pre> if len(x) 0: do_something() </pre>
5
1805
by: =?Utf-8?B?Y2FyYm8=?= | last post by:
I am getting odd behavior in my code, first I thought it was caused by SP1 but now I have the same issue with a vanilla version of VS 2005. When I execute a function that contains an if statement. i.e. Dim b As Boolean Dim i As Integer = 0 If b then i += 1 'point 1 msgbox(i.toString()) ' point 2
1
2582
by: Brian | last post by:
I have an ASP.NET page that uses a FormView and SqlDataSource. Within my page I want to change a string if a column within my database record is a certain value. Here is some sample code: <asp:Content ID="Content2" ContentPlaceHolderID="Main" Runat="Server"> <asp:FormView ID="FormView1" runat="server" Width="123px" DataKeyNames="property_key" DataSourceID="SqlDataSource1"> <ItemTemplate> <strong style="font-size: 12px">For...
8
5266
by: chromis | last post by:
Hi, I'm writing a contacts section for a cms on a website, I've decided to write the section in OO code. So far I have my Contacts object and a page structure I would use for a procedural site. /com/Contacts.cfc <cfcomponent displayname="Contact" output="false" hint="Contact component"> <!--- properties: used for self-documentation ---> <cfproperty name="dsn" displayname="dsn" hint="Contact id (UUID)" type="string" required="false"...
0
8352
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8802
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
8697
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
8579
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
7297
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...
0
4144
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.