Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-07-2009, 09:43 AM   #1
amiscus
Registered User
 
Join Date: Jul 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
amiscus is on a distinguished road
Compile Error

When I try to add a button to a form I get the follwoing error.

Compile error. in query expression 'AppLoadString([bw_tblBtnActions].[Description])'

I have other forms with buttons on them that jsut open reports. When I click any of them I get this next error.

Compile error: Invalid outside procedure

And i get taken to a VBA module that says the following

Option Compare Database
Option Explicit
SQLcode = "alter table pipe hsit add column Number counter(1,1);"
DoCmd.RunSQL SQLcode
Sub number()
End Sub

This is all greek to me. I treid to check the database references and none are missing. I also tried unchecking and rechecking the others but to reload the references but that had no effect as well. Is there some other reference i should add? My old database copies seem to work all right and they have the same references. If anyone ahs some ideas please let me know. Thanks.

amiscus is offline   Reply With Quote
Old 08-07-2009, 10:10 AM   #2
MSAccessRookie
AWF VIP
 
MSAccessRookie's Avatar
 
Join Date: May 2008
Location: Central NJ, USA
Posts: 3,428
Thanks: 13
Thanked 128 Times in 123 Posts
MSAccessRookie is a jewel in the rough MSAccessRookie is a jewel in the rough MSAccessRookie is a jewel in the rough
Re: Compile Error

Quote:
Originally Posted by amiscus View Post
When I try to add a button to a form I get the follwoing error.

Compile error. in query expression 'AppLoadString([bw_tblBtnActions].[Description])'

I have other forms with buttons on them that jsut open reports. When I click any of them I get this next error.

Compile error: Invalid outside procedure

And i get taken to a VBA module that says the following

Option Compare Database
Option Explicit
SQLcode = "alter table pipe hsit add column Number counter(1,1);"
DoCmd.RunSQL SQLcode
Sub number()
End Sub

This is all greek to me. I treid to check the database references and none are missing. I also tried unchecking and rechecking the others but to reload the references but that had no effect as well. Is there some other reference i should add? My old database copies seem to work all right and they have the same references. If anyone ahs some ideas please let me know. Thanks.
I am not sure what the intention of the code is, but it appears to be out of order. Try the following instead:
Code:
 
Option Compare Database
Option Explicit
Sub number()
    SQLcode = "alter table [pipe hsit] add column Number counter(1,1);"
    DoCmd.RunSQL SQLcode
End Sub
Note that the "[" and "]" characters have been added around "pipe hsit" on the assumption that "pipe hsit" was the name of the Table being altered. If this is not the case, then that part of the code will need to be modified,
__________________
No one is expected to know everything and we can all learn from each other if we try.

This forum is about taking the next step (or perhaps the next two steps) toward becoming a better Access programmer, and the AWF Forum Members will help you on your journey.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
MSAccessRookie is offline   Reply With Quote
Old 08-07-2009, 10:30 AM   #3
amiscus
Registered User
 
Join Date: Jul 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
amiscus is on a distinguished road
Re: Compile Error

I tried adding the bracekts but it still returns the errors. The weird thing is that pipe hsit is an old table I had that was renamed and then deleted. I don't understand why thre would be any references to it since the form and report and the new table and the new queries were all created after it was deleted.

amiscus is offline   Reply With Quote
Old 08-07-2009, 10:36 AM   #4
MSAccessRookie
AWF VIP
 
MSAccessRookie's Avatar
 
Join Date: May 2008
Location: Central NJ, USA
Posts: 3,428
Thanks: 13
Thanked 128 Times in 123 Posts
MSAccessRookie is a jewel in the rough MSAccessRookie is a jewel in the rough MSAccessRookie is a jewel in the rough
Re: Compile Error

Quote:
Originally Posted by amiscus View Post
I tried adding the bracekts but it still returns the errors. The weird thing is that pipe hsit is an old table I had that was renamed and then deleted. I don't understand why thre would be any references to it since the form and report and the new table and the new queries were all created after it was deleted.
If the table has been replaced in the database, then it probably needs to be replaced in this Query as well. The Alter command requires the table to exist inthe database before it can be executed.
__________________
No one is expected to know everything and we can all learn from each other if we try.

This forum is about taking the next step (or perhaps the next two steps) toward becoming a better Access programmer, and the AWF Forum Members will help you on your journey.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
MSAccessRookie is offline   Reply With Quote
Old 08-07-2009, 11:32 AM   #5
amiscus
Registered User
 
Join Date: Jul 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
amiscus is on a distinguished road
Re: Compile Error

It has been replaced. All of the queries were built with the new table that is named "pipeline historical." I have no idea were the references to the old table came from and I get the same error from forms that were built before this newest form.
amiscus is offline   Reply With Quote
Old 08-07-2009, 12:34 PM   #6
boblarson
Smeghead
 
boblarson's Avatar
 
Join Date: Jan 2001
Location: Oregon, USA
Posts: 32,068
Thanks: 97
Thanked 1,827 Times in 1,578 Posts
boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold
Re: Compile Error

Note that this:

Code:
Option Compare Database
Option Explicit
SQLcode = "alter table pipe hsit add column Number counter(1,1);"
DoCmd.RunSQL SQLcode
Sub number()
End Sub
is not within a sub. The Option Explicit and Option Compare Database are where they should be but there is something in the wrong place (see red):

Code:
Option Compare Database
Option Explicit
Sub number()
Dim SQLcode As String
SQLcode = "alter table pipe hsit add column Number counter(1,1);"
DoCmd.RunSQL SQLcode
End Sub
Second, the alter table statement seems off.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
boblarson is offline   Reply With Quote
Old 08-07-2009, 01:48 PM   #7
MSAccessRookie
AWF VIP
 
MSAccessRookie's Avatar
 
Join Date: May 2008
Location: Central NJ, USA
Posts: 3,428
Thanks: 13
Thanked 128 Times in 123 Posts
MSAccessRookie is a jewel in the rough MSAccessRookie is a jewel in the rough MSAccessRookie is a jewel in the rough
Re: Compile Error

Quote:
Originally Posted by amiscus View Post
It has been replaced. All of the queries were built with the new table that is named "pipeline historical." I have no idea were the references to the old table came from and I get the same error from forms that were built before this newest form.
Can you show the revised Query? And I agree with Bob Larson that the Alter Table Statement looks like it has a non-Access Syntax. Perhaps it was based on Oracle or SQL Server?

__________________
No one is expected to know everything and we can all learn from each other if we try.

This forum is about taking the next step (or perhaps the next two steps) toward becoming a better Access programmer, and the AWF Forum Members will help you on your journey.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by MSAccessRookie; 08-07-2009 at 01:54 PM.
MSAccessRookie is offline   Reply With Quote
Old 08-10-2009, 05:31 AM   #8
amiscus
Registered User
 
Join Date: Jul 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
amiscus is on a distinguished road
Re: Compile Error

Thanks for the help from eveyone but i just ended up importing all the new tables queries forms and reports in to an older, stable version of the database. Still don't know what was causing the error because everything works fine in the new combined version. Maybe some weird corruption issue.
amiscus is offline   Reply With Quote
Old 08-10-2009, 07:32 AM   #9
MSAccessRookie
AWF VIP
 
MSAccessRookie's Avatar
 
Join Date: May 2008
Location: Central NJ, USA
Posts: 3,428
Thanks: 13
Thanked 128 Times in 123 Posts
MSAccessRookie is a jewel in the rough MSAccessRookie is a jewel in the rough MSAccessRookie is a jewel in the rough
Re: Compile Error

Quote:
Originally Posted by amiscus View Post
Thanks for the help from eveyone but i just ended up importing all the new tables queries forms and reports in to an older, stable version of the database. Still don't know what was causing the error because everything works fine in the new combined version. Maybe some weird corruption issue.
Unless of course, there is an intermittant problem with the Query that you were originally asking about. If that is the case, then it is possible that the problem will return again at some time in the future. Until then, good luck with your work.
__________________
No one is expected to know everything and we can all learn from each other if we try.

This forum is about taking the next step (or perhaps the next two steps) toward becoming a better Access programmer, and the AWF Forum Members will help you on your journey.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
MSAccessRookie is offline   Reply With Quote
Old 09-28-2009, 02:21 AM   #10
Cam D
Registered User
 
Join Date: Jul 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Cam D is on a distinguished road
Re: Compile Error

my problem is that when i try to make a button it comes up with the same error messages as the OP then when i use the button it closes the form and opens VBA but with relationships it highlights onetomany.
Cam D is offline   Reply With Quote
Old 09-28-2009, 09:35 AM   #11
boblarson
Smeghead
 
boblarson's Avatar
 
Join Date: Jan 2001
Location: Oregon, USA
Posts: 32,068
Thanks: 97
Thanked 1,827 Times in 1,578 Posts
boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold
Re: Compile Error

Quote:
Originally Posted by Cam D View Post
my problem is that when i try to make a button it comes up with the same error messages as the OP then when i use the button it closes the form and opens VBA but with relationships it highlights onetomany.
What code is highlighted?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
boblarson is offline   Reply With Quote
Old 10-05-2009, 06:57 AM   #12
Cam D
Registered User
 
Join Date: Jul 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Cam D is on a distinguished road
Re: Compile Error

the whole code was allrelationships=onetomany but the highlighjted code was just onetomany
Cam D is offline   Reply With Quote
Old 10-05-2009, 07:49 AM   #13
boblarson
Smeghead
 
boblarson's Avatar
 
Join Date: Jan 2001
Location: Oregon, USA
Posts: 32,068
Thanks: 97
Thanked 1,827 Times in 1,578 Posts
boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold
Re: Compile Error

Quote:
Originally Posted by Cam D View Post
the whole code was allrelationships=onetomany but the highlighjted code was just onetomany
That response doesn't make sense to me. Are you saying you had a line of code which reads:

allrelationships=ontomany

in your VBA code? If so, I'm not surprised it errored there as that has no meaning at all, at least I can see none since you've provided no code whatsoever. How about posting the code you have and then highlighting the spot it throws the error.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
boblarson is offline   Reply With Quote
Old 10-05-2009, 10:39 AM   #14
Cam D
Registered User
 
Join Date: Jul 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Cam D is on a distinguished road
Re: Compile Error

the code was pre-made when i created the relationship the error appeared when i tried to use a button i made on a form.
Cam D is offline   Reply With Quote
Old 10-05-2009, 10:41 AM   #15
boblarson
Smeghead
 
boblarson's Avatar
 
Join Date: Jan 2001
Location: Oregon, USA
Posts: 32,068
Thanks: 97
Thanked 1,827 Times in 1,578 Posts
boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold
Re: Compile Error

Quote:
Originally Posted by Cam D View Post
the code was pre-made when i created the relationship the error appeared when i tried to use a button i made on a form.
I'm guessing that English is not your native language, correct? (due to the very short responses here).

Can you post your database? It might clear up many things.

Go here to find out how to post it.

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
boblarson is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sudden 'compile error. in query expression' songofsolon Queries 2 01-13-2010 10:16 AM
Help plz with sql syntax joet1984 Other Software 0 12-11-2008 05:50 PM
How to use VB to make a custom error msg to replace the default PK violation msg? oZone Modules & VBA 11 11-23-2008 04:17 PM
How do I trap error: "The text is too long to be edited." OldBirdman Modules & VBA 14 07-21-2008 02:04 PM
Help - Compile error?? marshamonkey Reports 2 07-20-2008 10:25 AM




All times are GMT -8. The time now is 07:40 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World