473,418 Members | 2,640 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,418 software developers and data experts.

Access Compile Error

4
Trying to do the most simple VBA code and can't get it to work. Tried the two methods below (and every different way you could think of doing it using these two methods) and got the same error message
Expand|Select|Wrap|Line Numbers
  1. Compile Error: 
  2.               Expected Function of variable
Can anybody please help?

Expand|Select|Wrap|Line Numbers
  1.    Dim dbs As Database
  2.     Dim RegionCode As String
  3.     Dim strSQL As String
  4.  
  5.     Set dbs = CurrentDb()
  6.  
  7.     strSQL = "SELECT MAX([HeadOfficeRegionCode]+0.1)FROM   tlkHeadOfficeRegion"
  8.  
  9.     RegionCode = CurrentDb.Execute(strSQL, dbFailOnError)
  10.     Me.HeadOfficeRegionCode.Text = RegionCode
  11.  
  12. ******************************************************************************************
  13.  
  14.    RegionCode = DoCmd.RunSQL("SELECT MAX([HeadOfficeRegionCode]  +0.1)  FROM tlkHeadOfficeRegion")
  15.  
  16.     HeadOfficeRegionCode.Text = RegionCode

Thx

Sean

Email address deleted per site rules!
Aug 28 '07 #1
10 2318
missinglinq
3,532 Expert 2GB
Site rules prohibit the posting of email addresses, and so yours has been removed from your original post.

Perhaps if you could explain your problem in a little more detail we could be of some assistence. Your code leaves me somewhat baffled as to exactly what you're trying to do, especially this portion:

MAX([HeadOfficeRegionCode]+0.1)

Linq ;0)>
Aug 28 '07 #2
SeanD
4
Site rules prohibit the posting of email addresses, and so yours has been removed from your original post.

Perhaps if you could explain your problem in a little more detail we could be of some assistence. Your code leaves me somewhat baffled as to exactly what you're trying to do, especially this portion:

MAX([HeadOfficeRegionCode]+0.1)

Linq ;0)>
************************************************** ******************************************

Thanks Linq, I wasen't aware of the email rule.

All i'm trying to do is select the largest value in the "HeadOfficeRegionCode" field of the table tlkHeadOfficeRegion, add .1 to it and return that value to a textbox called HeadOfficeRegionCode.

Get Lagest value from HeadOfficeRegionCode
Add: .01
Return to HeadOfficeRegionCode textbox


Hope that clears things up,

Thanks

Sean
Aug 28 '07 #3
Denburt
1,356 Expert 1GB
Well I don't see any error trapping so when you receive the error you should have a button that says debug. This will highlight the offending line and may help us resolve your problem.

There are so many ways this can be written but this may help.

Expand|Select|Wrap|Line Numbers
  1. Dim dbs As Database
  2.     Dim RegionCode As String
  3.     Dim strSQL As String
  4. Dim rs as recordset
  5.     Set dbs = CurrentDb()
  6.     strSQL = "SELECT MAX([HeadOfficeRegionCode]+0.1)FROM   
  7. tlkHeadOfficeRegion"
  8.  
  9. set rs = dbs.openrecordset(strSQL)
  10.     RegionCode = rs!MaxOfHeadOfficeRegionCode
  11.     Me!HeadOfficeRegionCode.Text = RegionCode
  12.  

Let us know if that helps you any.
Aug 28 '07 #4
Denburt
1,356 Expert 1GB
Also FYI don't forget to close the recordset and release any objects.

rs.close
set rs = nothing
Aug 28 '07 #5
missinglinq
3,532 Expert 2GB
I have merged your duplicate threads of this problem. When posting a question, please show a little patience as it sometimes takes 20 or 30 seconds for a post to go thru. Double posting makes it very hard for people to answer you especially if there are answers happening in all the threads you have started because they have to read 2 or more threads in order to see what has already been said.

Thank you for your attention in this matter.

Linq ;0)>
Aug 29 '07 #6
missinglinq
3,532 Expert 2GB
SeanD, you have posted this question three times within the past 24 hours! Your third post, like your second one, has been deleted! It was explained to you why you should not do this, and you have been asked politely to refrain from doing so in the future. If you continue to ignore this request, we will be forced to ban you from this site.

Please take the time to read the Posting Guidelines

Linq
Aug 29 '07 #7
NeoPa
32,556 Expert Mod 16PB
Sean,
A post count of 3 and you're already on my radar. Nice going!

Let's start again here. There are site rules that you've already been directed to so I won't repeat that. What I will say, however, is that simple courtesy demands that you reply to those who take the time to respond, even if simply to inform them that they were not what you were after.

Further, I only have the one copy of your question to go on but it's clear that you weren't very bothered to post it correctly. The error message is either a very strange one or you meant 'or' instead of 'of'. This is not the only example of writing the question wrongly that you clearly didn't check. This sort of laziness possibly saves you a couple of seconds but can add a fair amount of wasted time to everyone who tries to assist. If you seem to treat their time with such disrespect, do you really think they will be bothered with your problem when they see that?

It is very early days yet so this situation can be changed around if you would like it to. If this type of behaviour stops then we can very easily forget it ever happened. Alternatively, as you've already been told, much more of this type of posting will get your account banned and we'll never have to worry about each other again.
I sincerely hope we see the former and are able to provide you with lots more help in the future.

-NeoPa
Access Forum Leader.
Aug 29 '07 #8
SeanD
4
Thank you Denburt, that solves my problem. I didn't realize that you needed to use a DAO object when working with a local database.

Neopa - You're right, I should have used an or in the compile error statement. I'll try to proof read my posts more diligently next time.

Sean
Aug 29 '07 #9
NeoPa
32,556 Expert Mod 16PB
Thank you Denburt, that solves my problem. I didn't realize that you needed to use a DAO object when working with a local database.

NeoPa - You're right, I should have used an or in the compile error statement. I'll try to proof read my posts more diligently next time.

Sean
That's OK Sean.
I can understand the frustration of trying to wait for a solution when the problem is urgent.
There's always a "post and wait" element to getting new help from a web site though (by its very nature - however frustrating that is). The only immediate solution there is finding a problem that's already been answered.

Good luck with your project :)
Aug 29 '07 #10
Denburt
1,356 Expert 1GB
Thank you Denburt, that solves my problem. I didn't realize that you needed to use a DAO object when working with a local database.

Neopa - You're right, I should have used an or in the compile error statement. I'll try to proof read my posts more diligently next time.

Sean
Glad I could help, as I said there are so many ways this can be accomplished yet I have been using this method for so long it is usually the quickest way for me to spit it out.

As a quick note if you stick around for a while and try to share some of your knowledge with others then you will find your response times tend to get much shorter since you have an established reputation and the people you have tried to help will be much more inclined to respond as quickly as they can. Not that any one here put people off or try to make them wait it is just a busy, busy place with so many people the more people you get to know the better.

Good luck hope to see you round.

Also FYI and mentioned in
Aug 29 '07 #11

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

Similar topics

1
by: Peter Petrillo | last post by:
The Access development group here at this company has exported its reports in xml format from Access 2003. I have no influence on how they have created them. I received the following files xm...
6
by: Uttam | last post by:
Hello, I am using the code from Chapter 17 specifically the code from the font frmListFonts in my application. I have taken care to copy all the relevant modules / class modules into the...
2
by: Peter Mather | last post by:
Hi, I have struck problems when trying to convert an Access97 database to Access 2000. I get a compile Error when I start the database in Access 2000.. The message is Can't find project or...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
5
by: MLH | last post by:
I had a form (Form12) with a code error in it. I knew it was there. I even planned on fixing it (someday). I needed a comprehensive test of all my code so I clicked Debug, Compile All Modules. My...
3
by: buran | last post by:
Dear ASP.NET Programmers, I am trying to save a new created Word document, but getting the following the error. I granted the necessary rights to the ASPNET user, but I'm still getting this...
13
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate...
21
by: Bigpond News | last post by:
Work at a large site - 1000+ PC's. Mixture of Win98 & WinXP. Majority of applications using Access 97. If I compile the Acc97 application on a Win98 PC, the .mde will run perfectly on both...
5
by: lgeastwood | last post by:
I have a weird problem in Access 2007. I've been working in A07 for about 2 weeks when this thing began occurring. I'm working in the VB Code Editor and set break points for event procedures....
15
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I met with a strange issue that derived class function can not access base class's protected member. Do you know why? Here is the error message and code. error C2248:...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.