Access

M

MJV

I have a database built and I have a line of code to go
out and get the first two numbers typed in. I am useing
the code like this

Private Sub TxtEnter_AfterUpdate()
Dim AnyString, MyStr
AnyString = TxtEnter ' Define string.
If AnyString Then
MyStr = left(AnyString, 2) + "000" ' Returns "2".
txtSubAddress = MyStr
End If
End Sub
Well it works fine till I try it on another system. I get
a error and LEFT it highlighted.
Anyone have a clue?
 
C

ChrisJ

this is usually a references problem.
On your good system open the code window (alt-F11),select
tools - references.
Select each in turn, not the path and filename, and the
order in which they appear in the list.
Go find each file in explorer, and note its version number.

Repeat the same exercise on the bad machine.
Check the order first, then make sure that none are
missing, finally repeat the version exercise.
 
M

MJV

Thanks for the info.
I thought that was it but still a no go! I have checked
version and also setup a fix.BAT file to transfer the
file to the location on the PC. I aslo checked references
and got them to match up. All are loaded. I looked at the
system files and all are loaded.

References VBA, Access, stdole, ADODB, PdfLib
Current user Admin
Jet version 4.0

Still errors on the LEFT statment in the code. Still lost
for ideas.
 
T

Tim Ferguson

Private Sub TxtEnter_AfterUpdate()
AnyString = TxtEnter ' Define string.
If AnyString Then
MyStr = left(AnyString, 2) + "000" ' Returns "2".
txtSubAddress = MyStr
End If
End Sub
Well it works fine till I try it on another system. I get
a error and LEFT it highlighted.

This is a references problem:- the first thing to do is to check that the
required libraries are there, as you have already done. The other thing to
do is to check the _entire_ list of references in the dialog and see if
_anything_ is missing, even one you do not need. If there is, you should
remove it; locate the file and re-create the reference later if are likely
to need it in the future.

This is a recognised bug in Access, that _any_ missing reference is liable
to mess up built-in VBA functions.

PS
Dim AnyString, MyStr

This defines two Variants not two strings. You might be better off using

Dim AnyString As String
Dim MyStr As String

as a good habit.

BoL

Tim F
 
G

Guest

Thank you Chris and Tim,
It works great now.
I changed this Dim AnyString, MyStr
to
Dim AnyString As String
Dim MyStr As String
and updated the references and got rid of the trash.

Thanks for the help!
Mike
 

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