Hello,
I am using the code from Chapter 17 specifically the code from the
font frmListFonts in my application.
I have taken care to copy all the relevant modules / class modules
into the respective files / folders etc. Nevertheless, I get the
following error when I start my application:
Compile error; Sub or Function not defined
This error is displayed on the following line of which "GetDC" is
selected.
hdc = GetDC(HWND_DESK TOP)
I have all the 7 Class Modules from Ch17.mdb as also all the Modules.
These were exported from Ch17.mdb into a file and later imported into
my application.
I am unable to fathom what is going wrong here - can someone help?
Thanks in advance.
Uttam 6 2435
I don't have that book, but, GetDC is a so-called "windows API". It must be
defined in a DECLARE statement. See if you can find such a statement. If you
can't, that is the problem. If you can, try making it say PUBLIC DECLARE ...
(not PRIVATE DECLARE ...).
HTH,
TC
"Uttam" <u0***@usa.ne t> wrote in message
news:8a******** *************** ***@posting.goo gle.com... Hello,
I am using the code from Chapter 17 specifically the code from the font frmListFonts in my application.
I have taken care to copy all the relevant modules / class modules into the respective files / folders etc. Nevertheless, I get the following error when I start my application:
Compile error; Sub or Function not defined
This error is displayed on the following line of which "GetDC" is selected.
hdc = GetDC(HWND_DESK TOP)
I have all the 7 Class Modules from Ch17.mdb as also all the Modules. These were exported from Ch17.mdb into a file and later imported into my application.
I am unable to fathom what is going wrong here - can someone help?
Thanks in advance.
Uttam
Try posting the whole content of the module that gets the error. And be sure
to repeat exactly what the error is, & on what line it occurs.
HTH,
TC
"Uttam" <u0***@usa.ne t> wrote in message
news:8a******** *************** **@posting.goog le.com... Hello,
I tried Terry's solution. The declarations section does contain the code as suggested by Terry. Nevertheless the problem still occurs.
One thing I discovered was that when running the example in the book, there is one reference to Microsoft Forms 2.0 Object which I installed explicitly. The list of references in my app now match that in Chapter 17.
Still I get the problem.
Any other suggestions please?
Thanks
Uttam
"Terry Kreft" <te*********@mp s.co.uk> wrote in message
news:<bj******* ***@newsreaderg 1.core.theplane t.net>... Well the problem is most likely that you haven't declared GetDC or you haven't declared HWND_DESKTOP or they aren't in scope
To check which it is Open the code window put the cursor inside teh word GetDC Press Shift-F2 on the keyboard
If you've declared it and it is in scope the cursor will jump to the declaration
Then do the same with HWND_DESKTOP
Once you know which is missinig it is easy to declare them.
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Long) As Long Private Const HWND_DESKTOP = 0
both of which go in the declarations section of the module.
Terry
"Uttam" <u0***@usa.ne t> wrote in message news:8a******** *************** ***@posting.goo gle.com... Hello,
I am using the code from Chapter 17 specifically the code from the font frmListFonts in my application.
I have taken care to copy all the relevant modules / class modules into the respective files / folders etc. Nevertheless, I get the following error when I start my application:
Compile error; Sub or Function not defined
This error is displayed on the following line of which "GetDC" is selected.
hdc = GetDC(HWND_DESK TOP)
I have all the 7 Class Modules from Ch17.mdb as also all the Modules. These were exported from Ch17.mdb into a file and later imported into my application.
I am unable to fathom what is going wrong here - can someone help?
Thanks in advance.
Uttam
The important fact to realize -- ACCESS controls do not have HWNDs, except a
few of them do when they have the focus. Forms^3 (Forms 2.0) controls never
have HWNDs, at all. The book explains these facts.
--
MichKa [MS]
This posting is provided "AS IS" with
no warranties, and confers no rights.
"Uttam" <u0***@usa.ne t> wrote in message
news:8a******** *************** **@posting.goog le.com... Hello,
I tried Terry's solution. The declarations section does contain the code as suggested by Terry. Nevertheless the problem still occurs.
One thing I discovered was that when running the example in the book, there is one reference to Microsoft Forms 2.0 Object which I installed explicitly. The list of references in my app now match that in Chapter 17.
Still I get the problem.
Any other suggestions please?
Thanks
Uttam
"Terry Kreft" <te*********@mp s.co.uk> wrote in message
news:<bj******* ***@newsreaderg 1.core.theplane t.net>... Well the problem is most likely that you haven't declared GetDC or you haven't declared HWND_DESKTOP or they aren't in scope
To check which it is Open the code window put the cursor inside teh word GetDC Press Shift-F2 on the keyboard
If you've declared it and it is in scope the cursor will jump to the declaration
Then do the same with HWND_DESKTOP
Once you know which is missinig it is easy to declare them.
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Long) As Long Private Const HWND_DESKTOP = 0
both of which go in the declarations section of the module.
Terry
"Uttam" <u0***@usa.ne t> wrote in message news:8a******** *************** ***@posting.goo gle.com... Hello,
I am using the code from Chapter 17 specifically the code from the font frmListFonts in my application.
I have taken care to copy all the relevant modules / class modules into the respective files / folders etc. Nevertheless, I get the following error when I start my application:
Compile error; Sub or Function not defined
This error is displayed on the following line of which "GetDC" is selected.
hdc = GetDC(HWND_DESK TOP)
I have all the 7 Class Modules from Ch17.mdb as also all the Modules. These were exported from Ch17.mdb into a file and later imported into my application.
I am unable to fathom what is going wrong here - can someone help?
Thanks in advance.
Uttam
"Uttam" <u0***@usa.ne t> wrote... Thanks Terry for offering to help. Here goes:
I have marked the specific line where the error occurs with
"========>"
On that line the text "GetDC" is highlighted with a pop up message which says:
Compile Error. Sub or function not defined.
UM... Your Declare statement for GetDC is marked "Private" and its in
another module. Thus as far as your code is concerned, its not defined.
--
MichKa [MS]
This posting is provided "AS IS" with
no warranties, and confers no rights.
Hi Uttam
I'm TC, not Terry!
As the other respondent said, in Module1, you have "Private Declare..."
throughout. The Private keyword menas that each of those declarations is
only visible to code within Module1. It is not visible within any other
module. Try changing all those "Private"s to "Public"s, and try again (ie.
Public Declare...).
HTH,
TC
"Uttam" <u0***@usa.ne t> wrote in message
news:8a******** *************** ***@posting.goo gle.com... Thanks Terry for offering to help. Here goes:
I have marked the specific line where the error occurs with
"========>"
On that line the text "GetDC" is highlighted with a pop up message which says:
Compile Error. Sub or function not defined. Private Sub New_Font_List_C ombo_Load() '--------------------------------- ' ' This function fills in the array of suggested TrueType font sizes. ' It also fills in the array holding all the information about the ' available fonts. If the first font is a raster font, it gets the ' available font sizes for that font. ' Dim hdc As Long
On Error GoTo HandleErrors
mintCountTTSize s = 16 maintTTSizes = Array(8, 9, 10, 11, 12, 14, 16, _ 18, 20, 22, 24, 26, 28, 36, 48, 72) =======> hdc = GetDC(HWND_DESK TOP) If hdc <> 0 Then ' Get the number of fonts. mlngCountFonts = adh_accGetFontC ount(hdc) ' If there are fonts, dimension the array ' to be the right size. If mlngCountFonts > 0 Then ReDim mafiFonts(0 To mlngCountFonts - 1) ' Fill mafiFonts() with the font names. mlngCountFonts = adh_accGetFontL ist(hdc, mafiFonts()) End If <snip><snip><sn ip><snip><snip> <snip><snip><sn ip><snip><snip>
In Module1 where all my global variables and my commonly called sub routines are coded, I have the following code:
Option Explicit
' From Access 2000 Developer's Handbook, Volume I ' by Getz, Litwin, and Gilbert. (Sybex) ' Copyright 1999. All rights reserved.
' This module contains replacements for the font ' handling procedures provided by Access 97 internally. ' Because Access 2000 doesn't provide these procedures ' you can use these replacements for any existing ' code. You might want to investigate the ScreenInfo ' object for future development, as it provides ' this same information in a simpler manner.
' In this module: ' adh_accGetFontC ount ' adh_accGetFontL ist ' adh_accGetSizeC ount ' adh_accGetSizeL ist ' ' Requires: ' basCommon ' basFontCommon
' Indicate that a parameter for Quicksort is missing. Private Const dhcMissing = -2
' =============== = ' API Declarations ' =============== = Private Const LOGPIXELSX = 88 ' Logical pixels/inch in X Private Const LOGPIXELSY = 90 Private Const HWND_DESKTOP = 0 Private Const LF_FACESIZE = 32 Private Const DEFAULT_CHARSET = 1
Private Declare Function GetDeviceCaps _ Lib "gdi32" _ (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function MulDiv _ Lib "kernel32" _ (ByVal nNumber As Long, ByVal nNumerator As Long, _ ByVal nDenominator As Long) As Long
Private Declare Function EnumFontFamilie s _ Lib "gdi32" Alias "EnumFontFamili esA" _ (ByVal hdc As Long, ByVal lpszFamily As String, _ ByVal lpEnumFontFamPr oc As Long, ByVal lParam As Long) As Long
Private Declare Function CreateFontIndir ect _ Lib "gdi32" Alias "CreateFontIndi rectA" _ (lpLogFont As LOGFONT) As Long
Private Declare Function GetDC _ Lib "USER32" _ (ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC _ Lib "USER32" _ (ByVal hWnd As Long, ByVal hdc As Long) As Long
*-*-*-*-*-*-*-*-*-*-*
As you can see, I have GetDC defined above.
Just to explain, I have copied this "as is" from the book with only the variables names of the drop down box changed to match what is on my application.
Thanks once again.
Cheers!
Uttam
=============== =
"TC" <a@b.c.d> wrote in message news:<106351821 4.847834@teutho s>... Try posting the whole content of the module that gets the error. And be
sure to repeat exactly what the error is, & on what line it occurs.
HTH, TC
"Uttam" <u0***@usa.ne t> wrote in message news:8a******** *************** **@posting.goog le.com... Hello,
I tried Terry's solution. The declarations section does contain the code as suggested by Terry. Nevertheless the problem still occurs.
One thing I discovered was that when running the example in the book, there is one reference to Microsoft Forms 2.0 Object which I installed explicitly. The list of references in my app now match that in Chapter 17.
Still I get the problem.
Any other suggestions please?
Thanks
Uttam
"Terry Kreft" <te*********@mp s.co.uk> wrote in message news:<bj******* ***@newsreaderg 1.core.theplane t.net>... > Well the problem is most likely that you haven't declared GetDC or
you > haven't declared HWND_DESKTOP or they aren't in scope > > To check which it is > Open the code window > put the cursor inside teh word GetDC > Press Shift-F2 on the keyboard > > If you've declared it and it is in scope the cursor will jump to the > declaration > > Then do the same with HWND_DESKTOP > > Once you know which is missinig it is easy to declare them. > > Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal
hwnd As > Long) As Long > Private Const HWND_DESKTOP = 0 > > both of which go in the declarations section of the module. > > Terry > > "Uttam" <u0***@usa.ne t> wrote in message > news:8a******** *************** ***@posting.goo gle.com... > > Hello, > > > > I am using the code from Chapter 17 specifically the code from the > > font frmListFonts in my application. > > > > I have taken care to copy all the relevant modules / class modules > > into the respective files / folders etc. Nevertheless, I get the > > following error when I start my application: > > > > Compile error; Sub or Function not defined > > > > This error is displayed on the following line of which "GetDC" is > > selected. > > > > hdc = GetDC(HWND_DESK TOP) > > > > I have all the 7 Class Modules from Ch17.mdb as also all the
Modules. > > These were exported from Ch17.mdb into a file and later imported
into > > my application. > > > > I am unable to fathom what is going wrong here - can someone help? > > > > Thanks in advance. > > > > Uttam
I owe you an apology TC.
Converting to Public certainly works - now I have to grapple with some
other logical errors, which I will be able to solve by myself.
To all who responded to my query - THANK YOU all!
Cheers!
Uttam
=============== =
"TC" <a@b.c.d> wrote in message news:<106361564 3.882313@teutho s>... Hi Uttam
I'm TC, not Terry!
As the other respondent said, in Module1, you have "Private Declare..." throughout. The Private keyword menas that each of those declarations is only visible to code within Module1. It is not visible within any other module. Try changing all those "Private"s to "Public"s, and try again (ie. Public Declare...).
HTH, TC "Uttam" <u0***@usa.ne t> wrote in message news:8a******** *************** ***@posting.goo gle.com... Thanks Terry for offering to help. Here goes:
I have marked the specific line where the error occurs with
"========>"
On that line the text "GetDC" is highlighted with a pop up message which says:
Compile Error. Sub or function not defined. Private Sub New_Font_List_C ombo_Load() '--------------------------------- ' ' This function fills in the array of suggested TrueType font sizes. ' It also fills in the array holding all the information about the ' available fonts. If the first font is a raster font, it gets the ' available font sizes for that font. ' Dim hdc As Long
On Error GoTo HandleErrors
mintCountTTSize s = 16 maintTTSizes = Array(8, 9, 10, 11, 12, 14, 16, _ 18, 20, 22, 24, 26, 28, 36, 48, 72) =======> hdc = GetDC(HWND_DESK TOP) If hdc <> 0 Then ' Get the number of fonts. mlngCountFonts = adh_accGetFontC ount(hdc) ' If there are fonts, dimension the array ' to be the right size. If mlngCountFonts > 0 Then ReDim mafiFonts(0 To mlngCountFonts - 1) ' Fill mafiFonts() with the font names. mlngCountFonts = adh_accGetFontL ist(hdc, mafiFonts()) End If <snip><snip><sn ip><snip><snip> <snip><snip><sn ip><snip><snip>
In Module1 where all my global variables and my commonly called sub routines are coded, I have the following code:
Option Explicit
' From Access 2000 Developer's Handbook, Volume I ' by Getz, Litwin, and Gilbert. (Sybex) ' Copyright 1999. All rights reserved.
' This module contains replacements for the font ' handling procedures provided by Access 97 internally. ' Because Access 2000 doesn't provide these procedures ' you can use these replacements for any existing ' code. You might want to investigate the ScreenInfo ' object for future development, as it provides ' this same information in a simpler manner.
' In this module: ' adh_accGetFontC ount ' adh_accGetFontL ist ' adh_accGetSizeC ount ' adh_accGetSizeL ist ' ' Requires: ' basCommon ' basFontCommon
' Indicate that a parameter for Quicksort is missing. Private Const dhcMissing = -2
' =============== = ' API Declarations ' =============== = Private Const LOGPIXELSX = 88 ' Logical pixels/inch in X Private Const LOGPIXELSY = 90 Private Const HWND_DESKTOP = 0 Private Const LF_FACESIZE = 32 Private Const DEFAULT_CHARSET = 1
Private Declare Function GetDeviceCaps _ Lib "gdi32" _ (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function MulDiv _ Lib "kernel32" _ (ByVal nNumber As Long, ByVal nNumerator As Long, _ ByVal nDenominator As Long) As Long
Private Declare Function EnumFontFamilie s _ Lib "gdi32" Alias "EnumFontFamili esA" _ (ByVal hdc As Long, ByVal lpszFamily As String, _ ByVal lpEnumFontFamPr oc As Long, ByVal lParam As Long) As Long
Private Declare Function CreateFontIndir ect _ Lib "gdi32" Alias "CreateFontIndi rectA" _ (lpLogFont As LOGFONT) As Long
Private Declare Function GetDC _ Lib "USER32" _ (ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC _ Lib "USER32" _ (ByVal hWnd As Long, ByVal hdc As Long) As Long
*-*-*-*-*-*-*-*-*-*-*
As you can see, I have GetDC defined above.
Just to explain, I have copied this "as is" from the book with only the variables names of the drop down box changed to match what is on my application.
Thanks once again.
Cheers!
Uttam
=============== =
"TC" <a@b.c.d> wrote in message news:<106351821 4.847834@teutho s>... Try posting the whole content of the module that gets the error. And be sure to repeat exactly what the error is, & on what line it occurs.
HTH, TC
"Uttam" <u0***@usa.ne t> wrote in message news:8a******** *************** **@posting.goog le.com... > Hello, > > I tried Terry's solution. The declarations section does contain the > code as suggested by Terry. Nevertheless the problem still occurs. > > One thing I discovered was that when running the example in the book, > there is one reference to Microsoft Forms 2.0 Object which I installed > explicitly. The list of references in my app now match that in > Chapter 17. > > Still I get the problem. > > Any other suggestions please? > > Thanks > > Uttam > > > "Terry Kreft" <te*********@mp s.co.uk> wrote in message news:<bj******* ***@newsreaderg 1.core.theplane t.net>... > > Well the problem is most likely that you haven't declared GetDC or you > > haven't declared HWND_DESKTOP or they aren't in scope > > > > To check which it is > > Open the code window > > put the cursor inside teh word GetDC > > Press Shift-F2 on the keyboard > > > > If you've declared it and it is in scope the cursor will jump to the > > declaration > > > > Then do the same with HWND_DESKTOP > > > > Once you know which is missinig it is easy to declare them. > > > > Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As > > Long) As Long > > Private Const HWND_DESKTOP = 0 > > > > both of which go in the declarations section of the module. > > > > Terry > > > > "Uttam" <u0***@usa.ne t> wrote in message > > news:8a******** *************** ***@posting.goo gle.com... > > > Hello, > > > > > > I am using the code from Chapter 17 specifically the code from the > > > font frmListFonts in my application. > > > > > > I have taken care to copy all the relevant modules / class modules > > > into the respective files / folders etc. Nevertheless, I get the > > > following error when I start my application: > > > > > > Compile error; Sub or Function not defined > > > > > > This error is displayed on the following line of which "GetDC" is > > > selected. > > > > > > hdc = GetDC(HWND_DESK TOP) > > > > > > I have all the 7 Class Modules from Ch17.mdb as also all the Modules. > > > These were exported from Ch17.mdb into a file and later imported into > > > my application. > > > > > > I am unable to fathom what is going wrong here - can someone help? > > > > > > Thanks in advance. > > > > > > Uttam This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ronny Sigo |
last post by:
Hello all,
Ik have made an Access application on my computer which has a screen
resolution of 1024 x 768. However the goal is to run it on my girlfriend's
computer which has a screen resolution of 800 x 768. Of course on her
computer not all of the controls are visible and she must scroll to see them
all.
Is there a way to adapt this automatically ?
Any help very much appreciated.
Ronny
|
by: Colleyville Alan |
last post by:
I have a incremental search box that has been working fine for a couple of
months but is now acting up. This search box is from the cd that comes with
Getz's book, so I did not write it and have only a superficial understanding
of how it works.
I have had some trouble in the past when my code goes to another form and
comes back sometimes the search function did not work properly. Then I
added a line to requery it and it worked fine. ...
|
by: j.mandala |
last post by:
Someone is trying to run my Access 2002 database under Access 2003. He
has had a number of problems:
1) i used the MSComCt2.ocx for it's Date and Time picker. I can't find
it under 2003. Do I need to send it to them?
2) I have a function to fill a table with values, that store the page
and column numbers of a display of staff members. I had him check the
link to Microsoft DAO 3.6 Object Library under references, but it
still won't...
|
by: Adriaan van Heerden |
last post by:
hi,
once again apologies if I'm covering old ground. I've looked through
lots of previous posts and tried some code but nothing works as yet.
However, the problem must be a very common one so I'm slightly
surprised there isn't more on this (unless I'm missing something -- if
so please just point me in the right direction), and the textbooks are
also strangely silent.
I need to do the following:
|
by: corepaul |
last post by:
I am fairly new to Access and I have a problem trying to use bookmarks with
a recordset.
I have a recordset dimensioned as,
Dim rstFoodDesc As ADODB.Recordset ' recordset
Dim bMark As Variant ' variable to store bookmark
I open the recordset with the statements,
| |
by: Lee |
last post by:
Hello All,
First of all I would like to say thank you for all of the help I have
received here. I have been teaching myself Access for about 4 years
now and I've always been able to find a solution here - until now.
This one is driving me crazy.
I am making my first attempt at creating a runtime application. I am
using Access 2003 Developer Extensions. Initially I developed the
database without planning on creating a runtime app...
|
by: Brian Wilson |
last post by:
Hi Newsgroup!
I know many of you must have bought the Access Developer's Handbook and used
the Tagged Values class, so perhaps I can ask someone to check something.
On page 303, it describes the Add method of the class, and claims it returns
the TaggedValue item that was added. However, as far as I can see, it does
not provide a return value (despite being a function rather than a sub) so
cannot work as advertised.
Am I right in my...
|
by: MyPersonalSpamBot |
last post by:
Hey group,
I've been working as an access developer as part of my college co-op. I
am interested in learning more about Access, and I repeatedly see in
this newsgroup, "Read Access XXX Developer's Handbook" and that's what
I've decided to do.
What I'd like to know is, which version of the book should I get. I am
working in Access 2000, but I don't want to limit myself to that, I
would like a wider range of knowledge so I can easily...
|
by: Mark |
last post by:
Hi All,
I am creating a music database for a friend and have run into a problem.
Within the ALBUM table, I wanted to store the ARTIST_ID rather than the
ARTIST_NAME. To do this, I intended to have have a command button on the
album form which would open a search form (based on the artist table). This
works as I wanted and allows me to get to one record. I then planned to have
a button on the search form which when clicked, would updated...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |