473,385 Members | 1,402 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,385 software developers and data experts.

Calling a module function from a form - Compile error!

Hi!

I'm using MS Access 2002 and have troubles calling my function in a module I've created. When I try to even write the call of the function, it instantly gives me an error saying: "Compile Error Expected: (" eventhough I have the '(' in there. Sometimes it expects a '=' symbol instead, wanting me to bind the call to some variable I guess. What should I do? The function I'm calling does not return any parameters.

Here is my code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_generoi_Click()
  2.  
  3. Dim instr As String
  4. Dim motor As String
  5. Dim muu1 As String
  6. Dim muu2 As String
  7.  
  8. instr = instru_help.text
  9. motor = moot_help.text
  10. muu1 = muu1_help.text
  11. muu2 = muu2_help.text
  12.  
  13.  
  14. If instr <> "" then
  15.     replaceAliases.replaceAliases(False,instr)
  16. End If
  17.  
  18.  
  19. If muu1 <> "" Then
  20.     replaceAliases.replaceAliases (False,muu1)
  21. End If
  22.  
  23. If muu2 <> "" Then
  24.     replaceAliases.replaceAliases (False,muu2)
  25. End If
  26.  
  27. End Sub
  28.  
Oct 13 '06 #1
5 11314
Tanis
143 100+
Post the code for your function.
Oct 13 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
In access you don't need to refer to the module name when calling a function just the function name.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_generoi_Click()
  2.  
  3. Dim instr As String
  4. Dim motor As String
  5. Dim muu1 As String
  6. Dim muu2 As String
  7.  
  8. instr = instru_help.text
  9. motor = moot_help.text
  10. muu1 = muu1_help.text
  11. muu2 = muu2_help.text
  12.  
  13.  
  14. If instr <> "" then
  15. replaceAliases(False,instr)
  16. End If
  17.  
  18.  
  19. If muu1 <> "" Then
  20. replaceAliases (False,muu1)
  21. End If
  22.  
  23. If muu2 <> "" Then
  24. replaceAliases (False,muu2)
  25. End If
  26.  
  27. End Sub
  28.  
  29.  
Oct 14 '06 #3
Actually, often when I try to call simply the function name, Access wants to create a new macro or sub, which would be set to call the function. I wonder why is this?

Strangely, my problem got solved when I changed the name of one of my variables. I just changed
Expand|Select|Wrap|Line Numbers
  1.  Dim instr As String 
into
Expand|Select|Wrap|Line Numbers
  1.  Dim instru As String 
and the errors were gone. Still, I didn't even find any variables with the same name. I wonder what cause those errors in the first place...

In access you don't need to refer to the module name when calling a function just the function name.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_generoi_Click()
  2.  
  3. Dim instr As String
  4. Dim motor As String
  5. Dim muu1 As String
  6. Dim muu2 As String
  7.  
  8. instr = instru_help.text
  9. motor = moot_help.text
  10. muu1 = muu1_help.text
  11. muu2 = muu2_help.text
  12.  
  13.  
  14. If instr <> "" then
  15. replaceAliases(False,instr)
  16. End If
  17.  
  18.  
  19. If muu1 <> "" Then
  20. replaceAliases (False,muu1)
  21. End If
  22.  
  23. If muu2 <> "" Then
  24. replaceAliases (False,muu2)
  25. End If
  26.  
  27. End Sub
  28.  
  29.  
Oct 16 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
InStr is a function in access and therefore an illegal name. It was assuming you wanted to call the function.



Actually, often when I try to call simply the function name, Access wants to create a new macro or sub, which would be set to call the function. I wonder why is this?

Strangely, my problem got solved when I changed the name of one of my variables. I just changed
Expand|Select|Wrap|Line Numbers
  1.  Dim instr As String 
into
Expand|Select|Wrap|Line Numbers
  1.  Dim instru As String 
and the errors were gone. Still, I didn't even find any variables with the same name. I wonder what cause those errors in the first place...
Oct 16 '06 #5
Makes sense. Strange that the given error message didn't quite point to that direction, though...

InStr is a function in access and therefore an illegal name. It was assuming you wanted to call the function.
Oct 16 '06 #6

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

Similar topics

11
by: Tony Williams | last post by:
I have a module called GetDocIndex which calculates a sequential number in a control called CommDocNbrtxt. On the BeforeUpdate property of the form I have the following code Private Sub...
9
by: MLH | last post by:
Would the following work if placed in a form module rather than a global module? Declare Sub InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long)
2
by: Jeff Wilson | last post by:
Lots of posts explained to me how to invoke a function inside a form from another form. Unfortunately, it appears that a function inside a form can have at most 1 argument. I can create a form...
1
by: Pete Straman Straman via AccessMonster.com | last post by:
Hey: I have created a module that runs fine. I am trying to put all my modules on a form. I cannot get the modules to run from the command buttons. The error I get is Compiler error: ...
19
by: Ross A. Finlayson | last post by:
Hi, I hope you can help me understand the varargs facility. Say I am programming in ISO C including stdarg.h and I declare a function as so: void log_printf(const char* logfilename, const...
17
by: Bill Grigg | last post by:
I have been successfully calling DLL's using VC++ 6.0 and also using VC++7.1 (.NET). I only mention this because I have never felt comfortable with the process, but nonetheless it did work....
6
by: Amjad | last post by:
Hi, I want to make a project that calls and executes a function (VB code) made in a seperate file in the Application Folder. I know I can create the function in my project and call it internally,...
1
by: Maverick | last post by:
I'm trying to call on a function I created as follows. The stored functions is saved as : Public Function GetCaps(masterkey As String, id As String) ---All the code End Function I am calling...
10
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.