473,587 Members | 2,527 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_ReportChoi ces.CmdSave_to_ RTF_Click

Public Function Send_Report_to_ RTF()

Dim FormIsLoaded
FormIsLoaded = IsLoaded("Repor tChoices")
If FormIsLoaded = True Then
Form_ReportChoi ces.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 conObjStateClos ed = 0

IsLoaded = False
If SysCmd(acSysCmd GetObjectState, acForm, strFormName) <>
conObjStateClos ed Then
If Forms(strFormNa me).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

TIA, Rick
Nov 12 '05 #1
2 4593
"Rick Brown" <rb*******@comp userve.com> wrote in message
news:82******** *************** ***@posting.goo gle.com...
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_ReportChoi ces.CmdSave_to_ RTF_Click

Public Function Send_Report_to_ RTF()

Dim FormIsLoaded
FormIsLoaded = IsLoaded("Repor tChoices")
If FormIsLoaded = True Then
Form_ReportChoi ces.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 conObjStateClos ed = 0

IsLoaded = False
If SysCmd(acSysCmd GetObjectState, acForm, strFormName) <>
conObjStateClos ed Then
If Forms(strFormNa me).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("Repor tChoices") 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/AwUBP7A1LIechKq OuFEgEQKlLQCg89 tdcQABV6fQ3R0uC IVdYSbnSw8AoOI9
gg1dAw7/bDK37FGQhjH8yFM d
=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_ReportChoi ces.CmdSave_to_ RTF_Click

Public Function Send_Report_to_ RTF()

Dim FormIsLoaded
FormIsLoaded = IsLoaded("Repor tChoices")
If FormIsLoaded = True Then
Form_ReportChoi ces.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 conObjStateClos ed = 0

IsLoaded = False
If SysCmd(acSysCmd GetObjectState, acForm, strFormName) <>
conObjStateClos ed Then
If Forms(strFormNa me).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
9340
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 function, xfunc(A a), which wraps A::func(). For this to work properly, I need to make xfunc() a friend of class A. I am getting compile...
1
5449
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 "acVIEWPreview" versus "acPreview"?
2
3677
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 be able to make a DSN-Less connection so that my software is not dependent on having ODBC set-up with proper drivers and information. I have done...
1
10947
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 of the barcode plus a 1 character prefix. Test Data in table: SerialNumber
5
2219
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
1916
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 has a list of notes related to the Account-Master record (a relationship has been established based on the field CompanyID which exists in both...
7
2629
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 different kind of struct
10
2517
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 need. For example: delegate void callBackString(string d_string);
9
25745
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 &color and it should be a hexadecimal value. Then on the bottom of the page it says K. I've tried a lot of things like: &Kff0000 &K &ff0000 &...
0
7849
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8347
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.