This is probably an easy question. I am trying to use the debug window. I type the code in a module. Open the Debug window. Type in the name of the sub routine, hit enter and get “sub or function not defined”. I never use the debug window so what am I doing wrong???
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Debug window (Access 97)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Debug window (Access 97)
- This topic has 8 replies, 5 voices, and was last updated 22 years, 7 months ago.
Viewing 1 reply threadAuthorReplies-
WBell
AskWoody_MVPAugust 21, 2002 at 4:19 pm #610440I presume you are trying to run the code you just entered. Have you compiled it and saved it? That would seem to be the most logical explanation for the error you are getting. In any event, you can simply choose the run command from the module toolbar or menubar and execute the code. Hope this helps.
-
WSPaulK
AskWoody Lounger -
WSLindaR
AskWoody LoungerAugust 21, 2002 at 4:48 pm #610452This is the code I am using:
Private Sub ListFields()
Dim dbs As Database
Dim dbfield As Field
Dim tdf As TableDefSet dbs = CurrentDb
Set tdf = dbs.TableDefs!tblspecialistinfoEnd Sub
I want to get a list of fields in a table.
When I put Call ListFields in the debug window and hit enter – now the error is “Expected porocedure, Not variable”
It seems simple but I can’t seem to get it to work.
-
WScarbonnb
AskWoody LoungerAugust 21, 2002 at 11:04 pm #610515[indent]
Private Sub ListFields()
[/indent]This is why. You are making your sub a Private sub, which can only be referenced from another procedure in the same module.
If you want to run this sub from the debug window, you will need to change Private to Public or remove the word Private altogether.
The easies way to test a procedure (without any parameters required) is to put your insertion point anywhere in the procedure and then press F5 to run the code or F8 to single step through the code.
-
WSLindaR
AskWoody LoungerAugust 22, 2002 at 10:01 am #610593I give up, I have done everything everyone has suggested but I still get “function or sub not defined”. I took out private. I used F5 and F8 (it dings when I use these). I compiled all modules. This is what I am trying to run to get a listing of the fields in a table ( I added additional code):
Public Sub ListFields()
Dim dbs As Database
Dim dbfield As Field
Dim tdf As TableDef
Dim tblName As String
‘select table to listtblName = GetTableName
‘quit if name is a null string
If Trim(tblName) = “” Then Exit SubSet dbs = CurrentDb
Set tdf = dbs.TableDefs(tblName)
Debug.Print “”
Debug.Print “Table Name: ” & tdf.Name
Debug.Print “”For Each dbfield In tdf.Fields
Debug.Print dbfield.Name
Next dbfield‘release memory
Set dbs = Nothing‘open debug window
SendKeys “^g”End Sub
Function GetTableName()
Dim strinput As String, strMsg As String, q As Variant
‘function returns table name or null string if user cancelsstrMsg = “Enter Table Name:”
Repeat:
strinput = InputBox(Prompt:=strMsg, _
Title:=”List Table”, XPos:=2000, yPos:=2000)
If strinput = “” Then
GetTableName = “”
Else
q = MsgBox(“List able Named: ” & strinput, _
vbYesNoCancel + vbDefaultButton1, “Report Table”)
If q = vbCancel Then
GetTableName = “”
ElseIf q = vbNo Then
GoTo Repeat
Else
‘remove illegal leading and trailing spaces (if any)
GetTableName = Trim(strinput)
End If
End If
End Function -
WSHansV
AskWoody LoungerAugust 22, 2002 at 10:12 am #610608I copied your code into an Access 97 database and it runs OK.
Did you, by any chance, put the code into the module belonging to a form or report, or into a class module? You can’t just run procedures in those.
You need to put the code in a standard module. In Access 97, activate the Modules tab of the Database window, and click New, or select Insert/Module (NOT Insert/Class Module). Then, you should be able to run a procedure by putting the insertion point somewhere in it and pressing F5 (or F8 to single-step through it).
-
WSLindaR
AskWoody Lounger -
WSHansV
AskWoody Lounger
-
-
-
-
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Photos from iPhone to Win 10 duplicating/reformatting to .mov
by
J9438
1 hour, 6 minutes ago -
Thunderbird in trouble. Here comes Thundermail
by
Alex5723
3 hours, 15 minutes ago -
Get back ” Open With” in context menus
by
CWBillow
3 hours, 40 minutes ago -
Many AMD Ryzen 9800X3D on ASRock have died
by
Alex5723
7 hours, 27 minutes ago -
simple general stupid question
by
WSaltamirano
1 hour, 27 minutes ago -
Automatic Toggle code for pages and bookmarks for Table of Content (Awaiting moderation)
by
switchtolinux
11 hours, 49 minutes ago -
April 2025 Office non-Security updates
by
PKCano
3 hours, 33 minutes ago -
Microsoft wants to hear from you
by
Will Fastie
19 hours, 41 minutes ago -
Windows 11 Insider Preview Build 22635.5160 (23H2) released to BETA
by
joep517
22 hours, 2 minutes ago -
Europe Seeks Alternatives to U.S. Cloud Providers
by
Alex5723
1 day, 3 hours ago -
Test post
by
Susan Bradley
1 day, 5 hours ago -
Used Systems to delete Temp files Gone WRONG what does this mean?
by
Deo
1 day, 7 hours ago -
SSD shuts down on its own
by
CWBillow
22 hours, 52 minutes ago -
OneDrive File Sharing Changes
by
David Clark
1 day, 15 hours ago -
OneDrive File Sharing Changes
by
David Clark
1 day, 17 hours ago -
Win 10 Pro 22H2 to Win 11 Pro 23H2 Conversion Guide
by
doneager
17 hours, 39 minutes ago -
Today is world backup day
by
Alex5723
1 day, 9 hours ago -
Windows .exe on Mint
by
Slowpoke47
1 day, 19 hours ago -
Reviewing your licensing options
by
Susan Bradley
1 day, 4 hours ago -
Apple has been analyzing your photos since September 2024
by
B. Livingston
14 hours, 25 minutes ago -
What Windows 11 24H2 offers beyond bugs
by
Lance Whitney
10 hours, 16 minutes ago -
Making sense of Settings in Windows 11
by
Simon Bisson
11 hours, 36 minutes ago -
Windows 11 pro fails to log in after upgrading Win 10 pro to Win 11 pro 24h2
by
ben_sitaud
1 day, 15 hours ago -
23H2 / 24H2 / Local v. Microsoft Account.
by
CWBillow
1 day, 13 hours ago -
YouTube Ad Blocker Blocker
by
bbearren
1 day, 13 hours ago -
Obscure historical facts about Windows
by
Cybertooth
1 day, 15 hours ago -
Microsoft Backup
by
Linda2019
1 day, 6 hours ago -
What is the best notepad++ version for W7?
by
Picky
1 day, 14 hours ago -
What are right steps to move MS 365 Office+OneDrive files from PC to iMac?
by
glnz
2 days, 23 hours ago -
How to move existing MS 365 Office with OneDrive files from PC to new iMac
by
glnz
2 days, 23 hours ago
Recent blog posts
Key Links
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.