Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6665099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:41:13+00:00 2026-05-26T02:41:13+00:00

I have a problem that I have been trying to solve for a couple

  • 0

I have a problem that I have been trying to solve for a couple of days with MS Access and a VBA function.

To start I have a table as follows

Name = Team

fields are mostly text bases, unless stated otherwise
ID(autonumber primary key)
Non
Prenom
Location
TeamID (created by concatenting the Nom, Prenom and Location fields)

On my form I would like to extract the partial details entered into the Nom, Prenom, and Location fields. Then pass this back to the Database to enter into the TeamID field for the individual.

The extraction should take the form of
TeamID = mid(Location,0,4) & mid(Prenom,0,2) & mid(Nom,0,2à)

However I realise that I can’t put this into the ‘controle source’ section of the properties for any field.

So after much searching I decided that I should use a function in a separate module (I do this concatenating quite often for creation of ‘sensible’ index values on a large number of my tables, I find the autonumber primary key not very user friendly, or self explanatory.

So in my database file I created a module (called getInfo) with the public function

Public Function getID() As String
Dim r As String
Dim i As String
i = "Twenty"

Below are some of the options I have tried….

'r = VBA.Strings.UCase$(String:=i) 'turning the value of i to uppercase

getID = r 'returns "TWENTY" as expected

or

'r = VBA.Strings.Mid$("TWENTY", 0, 2)
getID = r 'error and highlights above line?

or

'r = StrReverse(i)
getID= r 'again error and highlights above line

getID = VBA.Strings.Mid$(String:="TWENTY", Start:=0, Length:=2)
End Function

I then opent eh ‘execution’ window and run the function.

I seem to be only able to convert the value to upper or lower case, any searching or manipulation of the string just gives me a message bow with the following error

Execution Error ‘5’
argument or procedure call incorrect

(please bear with me I am working on a french terminal and so my translation of this error may not be very acurate).

However all the functions come up correctly when I type them, as do the parameters being passed. when I search the net the info is also the same
http://www.techonthenet.com/excel/formulas/index_vba.php

So I am lost as to where I am going wrong.

I guess I am not declaring the value of my variables correctly, but I can’t see why.
This code doesn’t work elsewhere (other terminals) either, so I’m sure it must be my error!

But what is it.

I feel that this is a reallybasic problem, but just can’t get the function to work when manipulating a string.

Do I need to call this function from a sub only, and not directly, will this be the same on my form page?

I can create a minidatabase with just this code in if required.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:41:14+00:00Added an answer on May 26, 2026 at 2:41 am

    You should not need the VBA.String namespace prefix, and the ArgName:= syntax is optional so long as you follow same-order rules for optional paramaters.

    Mid$("TWENTY", 0, 2) fails because in VBA strings start at index 1, so Mid$("TWENTY", 1, 2) would return TW

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem that I have been trying to solve since days! I
I've been trying to solve a slow trigger problem and now that I have
I have been Googling a problem that I have with trying to integrate the
I have been trying to solve Project Euler's problem #59 for a while, and
I'm having a strange problem, that I've been trying to solve for too long.
I've got a rather tricky problem that I've been trying to solve for the
I have been trying to solve this problem all day, I googled a lot,
I have been trying to solve this strange problem with a website I am
I have been trying to solve this problem for hours (searched here as well
I'm still a beginner and I have been trying to solve this problem by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.