Results 1 to 4 of 4
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287

    Confused while creating formula

    Hey guys,



    I made a relatively simple formula:
    Code:
    Public Function First(Item As String, Vend As String, Major As String) As Integer
    Select Case Vend
        Case "SEAL", "TMPR"
            First = 4
        Case "ASHL"
            If Left(Item, 1) Like "M" Then
                First = 4
            Else
                Select Case Major
                    Case "1000", "2000", "2200", "1200", "2300"
                        First = 1
                    Case "1500", "2500", "2700", "1700", "2800", "2600"
                        First = 2
                    Case "3000", "3500", "3100", "3600", "3200", "3700"
                        First = 3
                    Case "5000", "5500", "5100", "5200"
                        First = 5
                    Case "6000", "6500", "6100", "6200"
                        First = 6
                    Case "4000", "4400", "4500", "7000", "7500", "4100", "7100", "4600"
                        First = 7
                    Case Else
                        First = 9
                End Select
            End If
    End Select
    Item, Vend, and Major are all pulled from our ODBC. I created a few other formulas that are all used in the same query as this. They all work great, except this one. I am getting the "wrong number of arguments" error when I try to exit that column in the query builder.

    Any ideas?

    Here is a snippet of the builder.
    Click image for larger version. 

Name:	Screen Shot 2014-12-09 at 3.59.54 PM.png 
Views:	8 
Size:	44.2 KB 
ID:	19013

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    The first (no pun intended) thing I would do is change the name of the function. First() is a aggregate function in SQL and is probably confusing Access.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Quote Originally Posted by pbaldy View Post
    The first (no pun intended) thing I would do is change the name of the function. First() is a aggregate function in SQL and is probably confusing Access.

    And fixed and working. Wow. /facepalm

    Appreciate it pbaldy!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 41
    Last Post: 05-29-2015, 02:58 PM
  2. Creating Billing System, self taught, and confused!
    By LethalMeatball in forum Access
    Replies: 7
    Last Post: 11-13-2013, 03:16 PM
  3. Need help creating a formula
    By Jimmy0291 in forum Queries
    Replies: 1
    Last Post: 01-17-2011, 12:12 PM
  4. Replies: 4
    Last Post: 08-16-2010, 10:46 AM
  5. Creating Formula In The Form
    By mastee in forum Access
    Replies: 3
    Last Post: 04-19-2010, 05:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums