473,388 Members | 1,375 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,388 software developers and data experts.

Proper Syntax

I'm trying to run code behind a command button from a command button
on another form but get an error on this line. I figure I've got the
syntax wrong for calling this command button? Whats the right syntax
and/or can I call it directly without using the function.

Form1 has a command button that calls the function: Call
Send_Report_to_RTF
The offending line is: Form_ReportChoices.CmdSave_to_RTF_Click

Public Function Send_Report_to_RTF()

Dim FormIsLoaded
FormIsLoaded = IsLoaded("ReportChoices")
If FormIsLoaded = True Then
Form_ReportChoices.CmdSave_to_RTF_Click
End If
End Function

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is loaded.

Const conDesignView = 0
Const conObjStateClosed = 0

IsLoaded = False
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

TIA, Rick
Nov 12 '05 #1
2 4586
"Rick Brown" <rb*******@compuserve.com> wrote in message
news:82**************************@posting.google.c om...
I'm trying to run code behind a command button from a command button
on another form but get an error on this line. I figure I've got the
syntax wrong for calling this command button? Whats the right syntax
and/or can I call it directly without using the function.

Form1 has a command button that calls the function: Call
Send_Report_to_RTF
The offending line is: Form_ReportChoices.CmdSave_to_RTF_Click

Public Function Send_Report_to_RTF()

Dim FormIsLoaded
FormIsLoaded = IsLoaded("ReportChoices")
If FormIsLoaded = True Then
Form_ReportChoices.CmdSave_to_RTF_Click
End If
End Function

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is loaded.

Const conDesignView = 0
Const conObjStateClosed = 0

IsLoaded = False
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

TIA, Rick

You won't be able to structure your code like that. Perhaps the easiest way
to re-structure would be to entirely delete the function
Send_Report_to_RTF() and then make the first line of the the click event for
'CmdSave_to_RTF' as shown below:

If Not IsLoaded("ReportChoices") Then Exit Sub

Alternatively have Send_Report_to_RTF() as a public function which is called
from the click event - but you can't call the code for a button's click
event from a public function.

HTH

Fletcher
Nov 12 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can't call a Private procedure (which all Control event procedures
default to) from another module.

The best solution (I can think of) is to move the code that is in the
CmdSave_to_RTF_Click procedure to a public procedure in a globally
accessible module. Then have the CommandButton's code just call this
procedure. Also, have your function "Send_Report_to_RTF" also call
this public procedure instead of calling the Private procedure
CmdSave_to_RTF_Click.

HTH,

MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP7A1LIechKqOuFEgEQKlLQCg89tdcQABV6fQ3R0uCIVdYS bnSw8AoOI9
gg1dAw7/bDK37FGQhjH8yFMd
=qVSN
-----END PGP SIGNATURE-----
Rick Brown wrote:
I'm trying to run code behind a command button from a command button
on another form but get an error on this line. I figure I've got the
syntax wrong for calling this command button? Whats the right syntax
and/or can I call it directly without using the function.

Form1 has a command button that calls the function: Call
Send_Report_to_RTF
The offending line is: Form_ReportChoices.CmdSave_to_RTF_Click

Public Function Send_Report_to_RTF()

Dim FormIsLoaded
FormIsLoaded = IsLoaded("ReportChoices")
If FormIsLoaded = True Then
Form_ReportChoices.CmdSave_to_RTF_Click
End If
End Function

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is loaded.

Const conDesignView = 0
Const conObjStateClosed = 0

IsLoaded = False
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

TIA, Rick

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Shea Martin | last post by:
I am trying to use a system call which takes a function ptr. My compiler won't compile the code if I give the system_call a ptr to a class member function, A::func(). To combat this, I created an...
1
by: ivan | last post by:
The OpenReport syntax listed in Access97 help for "view", is "acViewPreview"or "acViewNormal". I have been using "acPreview " and "acNormal" . Is there any difference in the results or usage of...
2
by: Kevin | last post by:
I am currently importing data into Access 2002 from 3 Sybase ASA 7.0 databases over a network. At this time I am using a ODBC System DSN connection using the proper ASA 7 driver. I would like to...
1
by: Rick Brown | last post by:
I'm trying to scan a barcode that contains the text string "BPWOT08762" into a textbox for use in a DLookup or query grid. I want to look thru a table's field that contains the last 6 characters...
5
by: Carlos Ojea Castro | last post by:
Hello: I want to display graphics from my postgresql database, but I must choose the proper tool first. Which one is more suitable?: perl? php? pg_autodoc? another one?
2
by: Swinky | last post by:
Can someone explain to me the proper syntax for requery and where to input it in my form? I have a main form "Account-Master" with two subforms: 1.) Contacts and 2.)TNotes. The TNotes subform...
7
by: Neil | last post by:
What I am doing wrong This works batPointer = adaptors.adaptor->batData; adaptors.batteries = batPointer->battery; where: batData is a pointer to a struct batPointer is a pointer to a...
10
by: Roger Frost | last post by:
Since we are currently on the subject of multi-threading in a different thread, I have a question about delegates. When I use delegates, I just create one for each different parameter set that I...
9
by: svdoerga | last post by:
I am wondering how you can change the fontcolor in the header or footer in VBA when exporting to excel. I need some text in red. I found the ms page with the codes here. It's saying the formatting is...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.