473,499 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling a sub from another sub and assigning value

232 New Member
on calling a sub from another sub and assigning value
it gives error
compile error:
expected function or variable
Please help as I tried many methods but failed

Expand|Select|Wrap|Line Numbers
  1. Sub MRKGRD(ByVal XX)
  2. If XX = "TR" Then
  3. MRKGRD = 444.4
  4. ElseIf XX = "IM" Then
  5. MRKGRD = 555.5
  6. ElseIf XX = "AB" Then
  7. MRKGRD = 666.6
  8. ElseIf XX = "TC" Then
  9. MRKGRD = 777.7
  10. ElseIf XX = "DA" Then
  11. MRKGRD = 888.8
  12. ElseIf XX = "BC" Then
  13. MRKGRD = 999.9
  14. Else
  15. MRKGRD = XX
  16. End If
  17. End Sub
  18. Sub updMRK()
  19. Dim AAA As DAO.Database
  20. Dim RSTREV As DAO.Recordset
  21.  
  22.    Set AAA = CurrentDb
  23.    Set RSTREV = AAA.OpenRecordset("SELECT * FROM REV")
  24.    RSTREV.MoveFirst
  25.    Do Until RSTREV.EOF
  26.     Set RSTAG = AAA.OpenRecordset("SELECT * FROM AAAAG WHERE SEQ='" & RSTREV("SEQ") & "'")
  27.          RSTAG.MoveFirst
  28.          RSTREV.Edit
  29.          For I = 1 To 10
  30.          RSTREV("SUB" & I) = RSTAG("SUB" & I)
  31.  
  32.  
  33.          RSTREV("MRK" & I & "_AA1") = MRKGRD(RSTAG("SUB" & I & "_AA1"))
  34.  
  35.     MsgBox "MARKS UPDATED"
  36. Next
  37.  
  38.          RSTREV.Update
  39.          RSTREV.MoveNext
  40.    Loop
  41.     MsgBox "MARKS UPDATED"
  42. End Sub
Jun 16 '16 #1
2 895
PhilOfWalton
1,430 Recognized Expert Top Contributor
It doesn't help not giving the line where the compile error is shown.

It doesn't help not giving a table structure.

In Sub updMRK(), you have not defined RSTAG as a recordset.

I don't like the look of
Expand|Select|Wrap|Line Numbers
  1.  Set RSTAG = AAA.OpenRecordset("SELECT * FROM AAAAG 
  2. WHERE SEQ='" & RSTREV("SEQ") & "'")
  3.  
Phil
Jun 16 '16 #2
MikeTheBike
639 Recognized Expert Contributor
Hi

As the error message suggests this statement
Expand|Select|Wrap|Line Numbers
  1. RSTREV("MRK" & I & "_AA1") = MRKGRD(RSTAG("SUB" & I & "_AA1"))
is expecting a variable OR Funtion on the right hand side, NOT a Sub() as you have.

You 'Sub' should be
Expand|Select|Wrap|Line Numbers
  1. Funtion MRKGRD(ByVal XX as String) as String
  2.  
  3. End Function
It is a long time since I used DAO, but from memeory don't you also need RSTREV.Update to save the data (but not in ADO)?

I also have doubts about it being a String function as you are retuning numeric values except for the 'Else' case.
What type of field are you saving the returned value to??

HTH


MTB
Jun 16 '16 #3

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

Similar topics

2
2381
by: Satish Chimakurthi | last post by:
Hi all, My question is surely a basic one, but somehow, I am not able to figure it out. I have a python file "satish.py" as follows: *satish.py* def main(): y()
6
1880
by: Asfand Yar Qazi | last post by:
Hi, Consider this: class C { int j; public: C(int i) : j(i)
1
2311
by: Shock | last post by:
Anybody ever tried to assign certain values in one datarow to certain locations in another datarow? Here is my code to this pont. Followed by the output from the command window in vs.net...
2
41261
by: | last post by:
Hi everyone, I have a form with a combo box on it. When you select a value (a PO#) from the combo box, the bound field is the indexID of the selected PO. On the same form, I have a text box...
3
1947
by: phish.guy | last post by:
How do I call another event's onclick function from a button press? I have stored information dynamically created in a div onclick function that is not accessible directly by the button, but i...
3
2622
by: solargovind | last post by:
Hi, How to get another Control value as a Default value of other control? For example, Whatever the value entered in Text1, need to come in Text 2 also. If require, the user can change the...
4
3306
jeffbroodwar
by: jeffbroodwar | last post by:
Hello, i have a problem about assigning a char value to a byte... please check the code below : ======================================================== Scenario # 1 : This code doesn't work : ...
8
6219
by: getmeidea | last post by:
Hi, I am using JDK 1.5. I have a program like this. Here i am directly assigning value to one object. It does'nt give me any compile time or run time error. In java we dont have access to any...
7
1522
by: Donos | last post by:
Hello I posted this earlier,but some how it's still not working for me. So i thought of giving a better description this time. The following is the code that am using, class CMyValue {...
9
1995
by: =?Utf-8?B?Q01hcnRpbg==?= | last post by:
How do I call the "buttonRun_Click()" method in C#? I can do this so easily in VB but I have yet to figuere out how in C#. I keep getting errors. Thanks CM
0
7132
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,...
0
7009
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...
0
7178
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,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
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...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
302
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.