Edit conditional statements in vba via form.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sashasandy
    New Member
    • Aug 2013
    • 14

    #1

    Edit conditional statements in vba via form.

    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?

    Code:
    Public Function ValGrade(PrMark As Double) As String
    Select Case PrMark
    Case 80 To 100
    ValGrade = "A"
    Case 75 To 80
    ValGrade = "A-"
    Case 70 To 74
    ValGrade = "B+"
    Case 65 To 69
    ValGrade = "B"
    Case 60 To 64
    ValGrade = "B-"
    Case 55 To 59
    ValGrade = "C+"
    Case 50 To 54
    ValGrade = "C"
    Case 45 To 49
    ValGrade = "C-"
    Case 40 To 44
    ValGrade = "D+"
    Case 35 To 39
    ValGrade = "D"
    Case 30 To 34
    ValGrade = "D-"
    Case Else
    ValGrade = "E"
    End Select
    End Function
    [imgnothumb]http://bytes.com/attachments/attachment/7179d1378193986/final.jpg[/imgnothumb]
    Attached Files
    Last edited by zmbd; Sep 3 '13, 12:39 PM. Reason: [z{placed pic inline}]
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    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

    Comment

    • sashasandy
      New Member
      • Aug 2013
      • 14

      #3
      thanks, surprisingly i have found the solution!!
      by using lookup in a simple query.

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1293

        #4
        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

        Comment

        • sashasandy
          New Member
          • Aug 2013
          • 14

          #5
          using a query instead of vba function.

          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

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            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.
            Last edited by zmbd; Sep 3 '13, 03:33 PM.

            Comment

            Working...