Re: Using a function to print



I'd suggest starting a new thread, as I've never used sysrel90

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"JIM" <JIM@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4BACA186-BB2F-4C06-869E-2E7439E19225@xxxxxxxxxxxxxxxx
Hi Doug, the link you referred to suggests using SYSREL90 so I downloaded
and
tried to run but can't get the syntax right. I'm using as a command:
C:\sysrel90.exe /srcdb <C:\ BTData.mdb> /destdb <[C:\ TempBT.mdb]>
Basically this transfers the relationships from one databae to another.
Do
you know if this is correct or should I repost?
Thanks, JIM

"Douglas J. Steele" wrote:

See whether you can find anything in the Corrupt Microsoft Access MDBs
FAQ
that Tony Toews has at http://www.granite.ab.ca/access/corruptmdbs.htm

Make sure you're working with a copy of the file, just in case it makes
it
worse!

Good luck.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"JIM" <JIM@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:88FE5053-221C-417B-B3A8-F8E887D6D0FF@xxxxxxxxxxxxxxxx
Thanks Doug for all your help so far. We are making progress. I tried
both
your suggestions - ran the msaccess.exe /decompile with no difference
access
reacted the same way and closed down. Then I tried creating a temp
database
and exported all objects into new database and recompiled and still
reacted
same way, same message. Any suggestion would be appreciated, JIM


"Douglas J. Steele" wrote:

Either create a new database and import everything from your current
database into it, or decompile your current database (see
http://www.mvps.org/access/bugs/bugs0008.htm for details on this
option)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"JIM" <JIM@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:96788382-DAD9-4AE1-9C8E-E743DD82B2D3@xxxxxxxxxxxxxxxx
Thanks Doug for all your help. My subroutine now looks like this:

Private Sub Option62_Click()
sFileName = Me.txtMapLoc
Call ExecuteFile(CStr(sFileName), "Print")
End Sub

It compiles without problems. When I click on command button a MS
message
comes up:
MSAccess for Windows has encountered a problem and needs to close.
We
are
sorry...... And then Access closes.
I'm using A2000. Do I need to update or is there another problem?
Thanks, JIM
I will leave town until 5/27


"Douglas J. Steele" wrote:

And sFileName is declared as a String both in Option62_Click and in
ExecuteFile?

You could try:

ExecuteFile(CStr(sFileName), "Print")

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"JIM" <JIM@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D092D212-81DB-46C9-AE01-685BBB9F8824@xxxxxxxxxxxxxxxx
Hi again, I closed my database and reopened and recompiled and am
now
back
at
first problem - it says there is a compile error: Byref argument
type
mismatch. It doesn't like sFileName.
Thanks, JIM

"Douglas J. Steele" wrote:

When you saved the code, you didn't happen to name the module
ExecuteFile
did you? If so, rename the module. Modules cannot have the same
name
as
subs
or functions.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"JIM" <JIM@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5CCDF4A2-3D53-47A4-A04B-52CB4C1975A9@xxxxxxxxxxxxxxxx
Thanks so much, Doug. I checked Require Variable Declar. and
added
option
explicit to module. Also reiterated the variables in
subroutine.
Now
it
says Compile error Expected Function or variable and
highlights
ExecuteFile.
In help it says:
The syntax of your statement indicates a variable or function
call.
This
error has the following cause and solution:
The name isn't that of a known variable or Function procedure.
Check the spelling of the name. Make sure that any variable or
function
with
that name is visible in the portion of the program from which
you
are
referencing it. For example, if a function is defined as
Private
or
a
variable isn't defined as Public, it's only visible within its
own
module.
(or)
You are trying to inappropriately assign a value to a
procedure
name.
For
example if MySub is a Sub procedure, the following code
generates
this
error:
MySub = 237 ' Causes Expected Function or variable error

Although you can use assignment syntax with a Property Let
procedure
or
with
a Function that returns an object or a Variant containing an
object,
you
can't use assignment syntax with a Sub, Property Get, or
Property
Set
procedure.

I've checked everything in help message. What am I missing?
Thanks, JIM

"Douglas J. Steele" wrote:

Try declaring sFileName:

Private Sub Option62_Click()
Dim sFileName As String
Dim vReturn As Variant

sFileName = Me.txtMapLoc
vReturn = ExecuteFile(sFileName, "Print")

End Sub

The fact that your code raised that error leads me to believe
that
you
haven't told Access to require declaration of all variables.
You
should.
To
do this, go into the VB Editor and select Tools | Options
from
the
menu
bar.
Look at the Editor tab: one of the options there should be
"Require
Variable
Declaration". What this means is that all future modules you
create
will
have Option Explicit as the first or second line of the file.
You
should
go
back to all of your existing modules and add that line. While
it
may
seem
like a lot of work declaring all your variables, in the long
run
it'll
save
you huge amounts of time as you try to figure out why your
code
isn't
doing
what it should when you've made a typo on a variable name!


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"JIM" <JIM@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B99C948D-2FFD-4A83-9FF1-BE1CAFAAC8CE@xxxxxxxxxxxxxxxx
I'm trying to make a function work found on-line. My
module
looks
like
this:
Option Compare Database

Public Const SW_Hide = 0
Public Const SW_Minimize = 6
Public Const SW_Restore = 9
Public Const SW_Show = 5
Public Const SW_ShowMazimized = 3
Public Const SW_ShowMinimized = 2
Public Const SW_ShowMinnoActive = 7
Public Const SW_Showna = 8
Public Const SW_ShownoActivate = 4
Public Const SW_ShowNormal = 1

Public Declare Function ShellExecute Lib "Shell32.dll"
Alias
"ShellExecuteA"
(ByVal hWnd As Long, ByVal IpOperation As String, ByVal
IpParameters
As
String, ByVal IpDirectory As String, ByVal nShowCmd As
Long)
As
Long

Public Sub ExecuteFile(sFileName As String, sAction As
String)
'sAction
can
be either "Open" or "Print"
Dim vReturn As Long

If ShellExecute(Access.hWndAccessApp, sAction,
sFileName,
vbNullString,
SW_ShowNormal) < 33 Then
MsgBox "File not found"
End If
End Sub

Then in my click event on a form the code looks like this:

Private Sub Option62_Click()
sFileName = Me.txtMapLoc
vReturn = ExecuteFile(sFileName, "Print")
End Sub

I get "Compile error: Byref argument type mismatch" And
after
thinking -
it's probably saying this is not a file name, which it is
not.
The
control
txtMapLoc has in it the location of the file (ie
F:Plans\Xcel.doc)
not
the
file name. How can I implement this function using the
location?
Thanks,
JIM

















.