5 Replies - 1154 Views - Last Post: 27 January 2014 - 11:06 PM Rate Topic: -----

#1 rebbael  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-December 13

Hello to all. An VBA code problem in Access 2013 I cannot solve...

Posted 09 December 2013 - 03:22 PM

Hi there. I'm an outmost noob as I can be, concerning VBA's but since I get around most software - a friend asked me for
a helping hand in some VBA tests, concerning Access 2013. And I don't want to disappoint her, plus I have about 5 hours to make this thing work, so if anyone can help ASAP - I thank you in advance.

The point is, I do not know how to write codes (a long long time ago I wrote some programs, following it line by line on an old Commodore 64 in Basic, which couldn't count for nothing nowadays), but step-by-step on this particular Access VBA assignment, everything went okay, I actually understood (well in a way) what was to be done and did it. But then an error appeared, regarding one part of the code, which I triple-checked and I re-typed the whole thing again, and again.
The same error is shown. I think the step-by-step assignment is flawed. At least this part I'm having trouble with.

I have put 2 pics with the links below. So hopefully someone can help me out while in the meantime I have several other projects to go through.

Posted Image

Posted Image

Thanks in advance!

R.

P.S.
I am sorry if I'm breaking any rules here - as you can see in the pics the only thing that is bothering me is the so-called Bonus code for Access database, you're not doing my homework assignment. I, as mentioned, believe that the PDF instructions are not correct and since I'm in no position of knowledge of Basic code to prove this (except the coding does not work) - thus I ask for some kinda guidance.
Thank you very much.

This post has been edited by modi123_1: 09 December 2013 - 03:25 PM
Reason for edit:: image tags for images, code tags for your text with code.


Is This A Good Question/Topic? 0
  • +

Replies To: Hello to all. An VBA code problem in Access 2013 I cannot solve...

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,293
  • Joined: 12-June 08

Re: Hello to all. An VBA code problem in Access 2013 I cannot solve...

Posted 09 December 2013 - 03:27 PM

Quote

thus I ask for some kinda guidance.

What's the problem? Is there an error message? If so what is it? Is the code not working as expected? Then tell folks what the code is doing versus what it should be doing.
Was This Post Helpful? 0
  • +
  • -

#3 rebbael  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-December 13

Re: Hello to all. An VBA code problem in Access 2013 I cannot solve...

Posted 09 December 2013 - 03:52 PM

Thank you for the speed modi!

I quote Microsoft Visual Basic for Applications:

"Compile error:
Variable not defined"

Then it goes to the 2nd pic I uploaded, highlighting with yellow (the start of Sub) and with blue intRating, which would be pointers for what is wrong, correct?
At that point, in Access the Shortcut button for this code freezes the program, while all other before this work as
they should.

Anyway for the hell of it, I selected everything, deleted it (actually cut it with ctrl+x, saved it in Notepad and
then copy pasted back everything and now it somehow works. I have no clue what happened. I thought I should re-arange
codes for each Access button/shortcut/what-have-you, but just this mere copy paste fixed everything and now it works.

Would someone explain how is this possible? Cuz now I'm getting curious and want to learn some tricks of the trade myself.

Again thanks for the fast reply. You can consider this topic closed, but I'd like to talk to someone about going deeper,
not just VBA but coding in general.

Thanks again & cheers!
Was This Post Helpful? 0
  • +
  • -

#4 mojo666  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 356
  • View blog
  • Posts: 785
  • Joined: 27-June 09

Re: Hello to all. An VBA code problem in Access 2013 I cannot solve...

Posted 09 December 2013 - 03:58 PM

The error is telling you that the compiler doesn't know what "intrating" is. The reason it doesn't know is because you didn't copy the code correctly and instead defined a variable "currating". Since you then copied the code directly with copy & paste, it now works.
Was This Post Helpful? 1
  • +
  • -

#5 rebbael  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-December 13

Re: Hello to all. An VBA code problem in Access 2013 I cannot solve...

Posted 09 December 2013 - 04:18 PM

View Postmojo666, on 09 December 2013 - 03:58 PM, said:

The error is telling you that the compiler doesn't know what "intrating" is. The reason it doesn't know is because you didn't copy the code correctly and instead defined a variable "currating". Since you then copied the code directly with copy & paste, it now works.


Actually, yes and no.
The code I was given to write in VBA was in PDF format and as a picture. So I couldn't copy/paste directly from the step-by step tutorial I have.
I said I copy/pasted the code with the mistake already in, first into notepad considering to re-align each code input (? is it input? sorry I am clearly not a programmer)
There are 5 codes for this Access database. Salaries, percentages, ratings, close form, and quit form. One of mentioned
gave me this negative compile message. Then I tried to copy/paste it back into an empty VBA Code Window and a miracle
happened.

Now, could you answer me here for another question?
How can I (there are about 15 people) make this code to automatically calculate with this same code the ratings and percentages? I have a table in Access and, obviously this Form which calculates only for the first person, and not for everyone else.

Thank you very much.
Was This Post Helpful? 0
  • +
  • -

#6 MBritton  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 27-January 14

Re: Hello to all. An VBA code problem in Access 2013 I cannot solve...

Posted 27 January 2014 - 11:06 PM

Change your declaration of the variable curRating to intRating.

It is a simple mix up.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1