Absolutely Crazy Error

J

jschping

Hi,

OK. This makes NO sense. I have 3 modules. One is the regular Concatenate by
Duane Hookum that works in tons of my applications. (I just modified it to
put in a carriage return, but that works fine in other applications.) That
code is at:
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=16

The second is a module to ascertain the width of a text box by Stephen
Lebans. Also, it works just fine in other applications. This can be found at:
http://www.lebans.com/textwidth-height.htm

I have a new application, and BOTH the above modules worked just fine and
did their jobs perfectly. Then I added the following new module and all heck
broke lose. Now as soon as I open the application I get an immediate error
message on the following line of code from Hookum's module:

If Len(strConcat) > 0 Then
strConcat = Left(strConcat, _
Len(strConcat) - Len(pstrDelim))
End If

The error says: "Compile Error. Array expected." But the vaiable strConcat
is declared as a string!! And it usually works fine!!!!

Here is the new module that causes (somehow) the trouble. I know that it's
the culprit since if I delete this module, the error goes away. It's to
modify a pop-up form to show a progress bar while the other code executes.

(Even weirder the code in the module ALSO worked! It was only after using it
a few times that the trouble started, without any changes (that I know of) to
the code. It's SO WEIRD. )

Please help!!!

Thanks,

John Schping

Option Compare Database
Option Explicit

Global The_Current_Percent As Integer
'Set a variable for the current percent
Global Original_Percent As Integer
'Set a variable for the percent that is being set by the code
Global Top, Left As Integer
'Set global size variables

Const Full_Width = 2.5 * 1440
'Set the full possible width of the status bar
Const WaitMessageHeight = 1.25 * 1440
Const WaitMessageWidth = 3.075 * 1440

Public Sub OpenWaitMessage()

Dim frm As Form

DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

Original_Percent = 0
The_Current_Percent = 0

frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

Top = 3.25 * 1440
Left = (([Forms]![Main_Student_Info_Form].WindowWidth - (3 * 1440)) / 2) + _
[Forms]![Main_Student_Info_Form].WindowLeft

DoCmd.MoveSize Left, Top

frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

DoEvents

End Sub

Public Sub Increment_Wait_Percentage()
'Increment the percentage if it's not 10 more than the last code-set
percentage

Dim frm As Form
DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

If The_Current_Percent < (Original_Percent + 10) Then
The_Current_Percent = The_Current_Percent + 1
frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

DoCmd.MoveSize Left, Top
frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

End If

End Sub

Public Sub Update_Wait_Percentage(New_Percent As Integer)

Dim frm As Form
DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

Original_Percent = New_Percent
The_Current_Percent = Original_Percent

frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

DoCmd.MoveSize Left, Top
frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

End Sub
Public Sub Close_Wait_Message()

DoCmd.Close acForm, "Wait_Message_Form"

End Sub
 
J

Jeff Boyce

One possibility is that there is some subtle corruption connected with that
new module.

Have you tried creating a new Access database, importing objects, and
re-downloading that new module's code?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

jschping said:
Hi,

OK. This makes NO sense. I have 3 modules. One is the regular Concatenate
by
Duane Hookum that works in tons of my applications. (I just modified it to
put in a carriage return, but that works fine in other applications.) That
code is at:
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=16

The second is a module to ascertain the width of a text box by Stephen
Lebans. Also, it works just fine in other applications. This can be found
at:
http://www.lebans.com/textwidth-height.htm

I have a new application, and BOTH the above modules worked just fine and
did their jobs perfectly. Then I added the following new module and all
heck
broke lose. Now as soon as I open the application I get an immediate error
message on the following line of code from Hookum's module:

If Len(strConcat) > 0 Then
strConcat = Left(strConcat, _
Len(strConcat) - Len(pstrDelim))
End If

The error says: "Compile Error. Array expected." But the vaiable strConcat
is declared as a string!! And it usually works fine!!!!

Here is the new module that causes (somehow) the trouble. I know that it's
the culprit since if I delete this module, the error goes away. It's to
modify a pop-up form to show a progress bar while the other code executes.

(Even weirder the code in the module ALSO worked! It was only after using
it
a few times that the trouble started, without any changes (that I know of)
to
the code. It's SO WEIRD. )

Please help!!!

Thanks,

John Schping

Option Compare Database
Option Explicit

Global The_Current_Percent As Integer
'Set a variable for the current percent
Global Original_Percent As Integer
'Set a variable for the percent that is being set by the code
Global Top, Left As Integer
'Set global size variables

Const Full_Width = 2.5 * 1440
'Set the full possible width of the status bar
Const WaitMessageHeight = 1.25 * 1440
Const WaitMessageWidth = 3.075 * 1440

Public Sub OpenWaitMessage()

Dim frm As Form

DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

Original_Percent = 0
The_Current_Percent = 0

frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

Top = 3.25 * 1440
Left = (([Forms]![Main_Student_Info_Form].WindowWidth - (3 * 1440)) / 2) +
_
[Forms]![Main_Student_Info_Form].WindowLeft

DoCmd.MoveSize Left, Top

frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

DoEvents

End Sub

Public Sub Increment_Wait_Percentage()
'Increment the percentage if it's not 10 more than the last code-set
percentage

Dim frm As Form
DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

If The_Current_Percent < (Original_Percent + 10) Then
The_Current_Percent = The_Current_Percent + 1
frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

DoCmd.MoveSize Left, Top
frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

End If

End Sub

Public Sub Update_Wait_Percentage(New_Percent As Integer)

Dim frm As Form
DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

Original_Percent = New_Percent
The_Current_Percent = Original_Percent

frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

DoCmd.MoveSize Left, Top
frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

End Sub
Public Sub Close_Wait_Message()

DoCmd.Close acForm, "Wait_Message_Form"

End Sub
 
J

Jonathan Wood

jschping said:
OK. This makes NO sense. I have 3 modules. One is the regular Concatenate
by
Duane Hookum that works in tons of my applications. (I just modified it to
put in a carriage return, but that works fine in other applications.) That
code is at:
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=16

The second is a module to ascertain the width of a text box by Stephen
Lebans. Also, it works just fine in other applications. This can be found
at:
http://www.lebans.com/textwidth-height.htm

I have a new application, and BOTH the above modules worked just fine and
did their jobs perfectly. Then I added the following new module and all
heck
broke lose. Now as soon as I open the application I get an immediate error
message on the following line of code from Hookum's module:

If Len(strConcat) > 0 Then
strConcat = Left(strConcat, _
Len(strConcat) - Len(pstrDelim))
End If

I'm not sure exactly what is causing this error (you might double check your
declarations if you, by chance, are not using Option Explicit).

But I would definitely rewrite this code you posted:

If Len(strConcat) > Len(pstrDelim) Then
strConcat = Left$(strConcat, Len(strConcat) - Len(pstrDelim))
End If

This version not only checks if Len(strConcat) > 0, but it also ensures
strConcat is longer than pstrDelim; otherwise, this could would raise an
error.
 
S

Steve Sanford

Global Top, Left As Integer
'Set global size variables

Also, "Top", "Left" are reserved words and should not be used as object
names. LEFT is also a function.

As it is written, "Top" is declared as a variant, not as an integer. In VBA,
you must explicitly declare each variable's type. It should be written:
Global Top As Integer, Left As Integer
'Set global size variables



HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


jschping said:
Hi,

OK. This makes NO sense. I have 3 modules. One is the regular Concatenate by
Duane Hookum that works in tons of my applications. (I just modified it to
put in a carriage return, but that works fine in other applications.) That
code is at:
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=16

The second is a module to ascertain the width of a text box by Stephen
Lebans. Also, it works just fine in other applications. This can be found at:
http://www.lebans.com/textwidth-height.htm

I have a new application, and BOTH the above modules worked just fine and
did their jobs perfectly. Then I added the following new module and all heck
broke lose. Now as soon as I open the application I get an immediate error
message on the following line of code from Hookum's module:

If Len(strConcat) > 0 Then
strConcat = Left(strConcat, _
Len(strConcat) - Len(pstrDelim))
End If

The error says: "Compile Error. Array expected." But the vaiable strConcat
is declared as a string!! And it usually works fine!!!!

Here is the new module that causes (somehow) the trouble. I know that it's
the culprit since if I delete this module, the error goes away. It's to
modify a pop-up form to show a progress bar while the other code executes.

(Even weirder the code in the module ALSO worked! It was only after using it
a few times that the trouble started, without any changes (that I know of) to
the code. It's SO WEIRD. )

Please help!!!

Thanks,

John Schping

Option Compare Database
Option Explicit

Global The_Current_Percent As Integer
'Set a variable for the current percent
Global Original_Percent As Integer
'Set a variable for the percent that is being set by the code
Global Top, Left As Integer
'Set global size variables

Const Full_Width = 2.5 * 1440
'Set the full possible width of the status bar
Const WaitMessageHeight = 1.25 * 1440
Const WaitMessageWidth = 3.075 * 1440

Public Sub OpenWaitMessage()

Dim frm As Form

DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

Original_Percent = 0
The_Current_Percent = 0

frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

Top = 3.25 * 1440
Left = (([Forms]![Main_Student_Info_Form].WindowWidth - (3 * 1440)) / 2) + _
[Forms]![Main_Student_Info_Form].WindowLeft

DoCmd.MoveSize Left, Top

frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

DoEvents

End Sub

Public Sub Increment_Wait_Percentage()
'Increment the percentage if it's not 10 more than the last code-set
percentage

Dim frm As Form
DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

If The_Current_Percent < (Original_Percent + 10) Then
The_Current_Percent = The_Current_Percent + 1
frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

DoCmd.MoveSize Left, Top
frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

End If

End Sub

Public Sub Update_Wait_Percentage(New_Percent As Integer)

Dim frm As Form
DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

Original_Percent = New_Percent
The_Current_Percent = Original_Percent

frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

DoCmd.MoveSize Left, Top
frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

End Sub
Public Sub Close_Wait_Message()

DoCmd.Close acForm, "Wait_Message_Form"

End Sub
 
J

jschping

Thanks so much! I think it was that they were reserved words and my using
"Left" as a variable messed up its use as the function later.

Once I changed the variable names everything worked perfectly.

Thanks again,

John Schping

Steve Sanford said:
Global Top, Left As Integer
'Set global size variables

Also, "Top", "Left" are reserved words and should not be used as object
names. LEFT is also a function.

As it is written, "Top" is declared as a variant, not as an integer. In VBA,
you must explicitly declare each variable's type. It should be written:
Global Top As Integer, Left As Integer
'Set global size variables



HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


jschping said:
Hi,

OK. This makes NO sense. I have 3 modules. One is the regular Concatenate by
Duane Hookum that works in tons of my applications. (I just modified it to
put in a carriage return, but that works fine in other applications.) That
code is at:
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=16

The second is a module to ascertain the width of a text box by Stephen
Lebans. Also, it works just fine in other applications. This can be found at:
http://www.lebans.com/textwidth-height.htm

I have a new application, and BOTH the above modules worked just fine and
did their jobs perfectly. Then I added the following new module and all heck
broke lose. Now as soon as I open the application I get an immediate error
message on the following line of code from Hookum's module:

If Len(strConcat) > 0 Then
strConcat = Left(strConcat, _
Len(strConcat) - Len(pstrDelim))
End If

The error says: "Compile Error. Array expected." But the vaiable strConcat
is declared as a string!! And it usually works fine!!!!

Here is the new module that causes (somehow) the trouble. I know that it's
the culprit since if I delete this module, the error goes away. It's to
modify a pop-up form to show a progress bar while the other code executes.

(Even weirder the code in the module ALSO worked! It was only after using it
a few times that the trouble started, without any changes (that I know of) to
the code. It's SO WEIRD. )

Please help!!!

Thanks,

John Schping

Option Compare Database
Option Explicit

Global The_Current_Percent As Integer
'Set a variable for the current percent
Global Original_Percent As Integer
'Set a variable for the percent that is being set by the code
Global Top, Left As Integer
'Set global size variables

Const Full_Width = 2.5 * 1440
'Set the full possible width of the status bar
Const WaitMessageHeight = 1.25 * 1440
Const WaitMessageWidth = 3.075 * 1440

Public Sub OpenWaitMessage()

Dim frm As Form

DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

Original_Percent = 0
The_Current_Percent = 0

frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

Top = 3.25 * 1440
Left = (([Forms]![Main_Student_Info_Form].WindowWidth - (3 * 1440)) / 2) + _
[Forms]![Main_Student_Info_Form].WindowLeft

DoCmd.MoveSize Left, Top

frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

DoEvents

End Sub

Public Sub Increment_Wait_Percentage()
'Increment the percentage if it's not 10 more than the last code-set
percentage

Dim frm As Form
DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

If The_Current_Percent < (Original_Percent + 10) Then
The_Current_Percent = The_Current_Percent + 1
frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

DoCmd.MoveSize Left, Top
frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

End If

End Sub

Public Sub Update_Wait_Percentage(New_Percent As Integer)

Dim frm As Form
DoCmd.OpenForm "Wait_Message_Form"
Set frm = Forms("Wait_Message_Form")

Original_Percent = New_Percent
The_Current_Percent = Original_Percent

frm.Box_Status.Width = (The_Current_Percent / 100) * Full_Width
'Reset the staus box to be the width of the percentage
frm.Percentage.Caption = The_Current_Percent & " %"
'Set the percentage label

DoCmd.MoveSize Left, Top
frm.InsideHeight = WaitMessageHeight
frm.InsideWidth = WaitMessageWidth

frm.Repaint

End Sub
Public Sub Close_Wait_Message()

DoCmd.Close acForm, "Wait_Message_Form"

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top