-
WSBart
AskWoody LoungerHi,
You use the brackets on anything you define yourself.
Me![TableName].SetFocus is the correct notation.
Me is a preserved word in VBA, so it should not be between brackets.
TableName is the name you gave to the table, this should be between brackets.
SetFocus is a method of the table object and should not be between brackets.
Using the brackets enables you to use spaces in naming your objects. I never do that, becaus I think it makes your code unreadable. I normally use capitals (for instance in tblThisIsMyTable).The + sign in front of your records indicates there is a one to many relation ship between the two tables. It is not an indication of a query!
If you click the + it simply opens the many branch of the relationship. -
WSBart
AskWoody LoungerI agree with grugeon.
Can you give more details on what you want to do?
Do you want to append records to your table or do you want to update existing records in your table?If you get error messages please post the exact error message and the SQL that causes the error.
-
WSBart
AskWoody LoungerIt’s the VBA.
Looks like Excel 2000 has protected every piece of code I wrote previously.
Can it be some sort of tremendous safety feature (probably called bug by a lot of people) the guys in Redmond has put in their product? -
WSBart
AskWoody LoungerHi,
To secure my databases I allways present them as a .MDE to my users. That prevents a lot of playing around in the code.
Also I make sure that in the startup procedure of my application the following code is executed to restrict users to access the application in design mode:If Command = “Debug” Then
fnChangeProperty “StartupShowDBWindow”, dbBoolean, True
fnChangeProperty “AllowBuiltinToolbars”, dbBoolean, True
fnChangeProperty “AllowToolbarChanges”, dbBoolean, True
fnChangeProperty “AllowShortcutMenus”, dbBoolean, True
fnChangeProperty “AllowFullMenus”, dbBoolean, True
fnChangeProperty “AllowBreakIntoCode”, dbBoolean, True
fnChangeProperty “AllowSpecialKeys”, dbBoolean, True
fnChangeProperty “AllowBypassKey”, dbBoolean, True
Else
fnChangeProperty “StartupShowDBWindow”, dbBoolean, False
fnChangeProperty “AllowBuiltinToolbars”, dbBoolean, False
fnChangeProperty “AllowToolbarChanges”, dbBoolean, False
fnChangeProperty “AllowShortcutMenus”, dbBoolean, False
fnChangeProperty “AllowFullMenus”, dbBoolean, False
fnChangeProperty “AllowBreakIntoCode”, dbBoolean, False
fnChangeProperty “AllowSpecialKeys”, dbBoolean, False
fnChangeProperty “AllowBypassKey”, dbBoolean, False
End If—————-
fnChangeProperty looks like this:Function fnChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
‘******************************************************************
‘SUB: fnChangeProperty
‘
‘Wijzigen van de startup properties.
‘Als de aangeroepen property nog niet bestaat, dan wordt deze aangemaakt.
‘
‘AANROEP: fnChangeProperty par1, par2, par3
‘
‘RETOUR: True (-1) indien aanroep ok
‘ False (0) indien fout
‘
‘LAATSTE WIJZIGING:
‘ Versie 1.0 februari 1999 B. Stam
‘ Initiele versie van de functie
‘******************************************************************
If gTrace Then Debug.Print “baszsfrmSplash fnChangeProperty”
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270Set dbs = CurrentDb
On Error GoTo fnChangeProperty_Err
dbs.Properties(strPropName) = varPropValue
fnChangeProperty = TruefnChangeProperty_Exit:
Set dbs = Nothing
Exit FunctionfnChangeProperty_Err:
‘******************************************************************
‘Als propertie niet gevonden, dan aanmaken.
‘******************************************************************
If Err = conPropNotFoundError Then ‘ Property not found.
Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
‘******************************************************************
‘Als er een andere fout is, dan maar negeren.
‘******************************************************************
Else
fnChangeProperty = False
Resume fnChangeProperty_Exit
End If
End Function————————-
Most users will not be able to hack this and change the design of an application.
If a user manage to change the design, you should consider to invide him or her to be a member of your team! -
WSBart
AskWoody LoungerThanks Rory, you gave me the solution.
I didn’t read the invaluable information under the F1 button completely and overlooked the second parameter on the Column property. -
WSBart
AskWoody LoungerHi,
Did you check if your references all still correct?
Do you use a function from a dll that is not present?
Can you post the exact error message you get, that can give a clue to the solution of your problem. -
WSBart
AskWoody LoungerYes, that should work.
Although, if you apply a naming convention, you would call it txtContactName (that is the name of the control on your form or report) and put in the caption of the label (with the name lblContactName) &Name, ensuring the hotkey for the field is ALT+N. -
WSBart
AskWoody LoungerYou can use the content of a textbox in a query with a LIKE operator.
Check Woody’s Access Watch #3.02 (yes the latest one). Here you will find a description and some examples of the LIKE operator.
-
WSBart
AskWoody LoungerLike Charlotte says, name is a preserved word in VBA.
You will net get problems like this if you apply a naming convention like LNC. Check Woody’s Access Watch #3.02 (yes the latest one). Here you will find a description of naming conventions.Bart
-
WSBart
AskWoody LoungerLike this:
DoCmd.OpenReport “R1”, acPreview, , sizing(Gebinde)
Public Function sizing(Gebinde) as string
If Gebinde = 1 Then
sizing = StrDrums
else
sizing = “”
End If
End FunctionBart
-
WSBart
AskWoody LoungerOK I want to suggest a couple of changes to your query.
First replace the DISTINCTROW by DISTINCT.Show only the fields you want to see, and no more. Your query looks like this:
SELECT DISTINCT field1, field2, field3 FROM ….
After FROM put only those tables you need for the fields you want to see and the ID’s from your subselects (see further).Now the WHERE clause, use subqueries here.
A subquery looks like this:
SELECT DISTINCT field1, field2, field3 FROM ….
WHERE ID IN (SELECT ID FROM table1 etc WHERE field1 LIKE etc.)You can store subqueries in seperate queries.
I think if you do all this, your query looks a lot different and it will work.
Success.
Bart
-
WSBart
AskWoody LoungerThere must be a unique field in the query (before the FROM).
Do all fields in two different rows have the same content?Bart
-
WSBart
AskWoody LoungerThere is an advantage putting the code in a module.
If you don’t have any code at all in the module attached to a form, you can set the HasModule property of that form to False. The form then does not have a module anymore resulting in a quicker load of the form.
If you load a form it’s module is loaded too, if the form doesn’t have a module that part isn’t carried out anymore.Bart
-
WSBart
AskWoody LoungerYes, it is possible.
I developed a class module that’ll do the job.
It uses de default mail client to send the mail.
Sorry, comments are dutch but the code is pretty self explaining.Option Compare Database
Option Explicit
‘*******************************************************
‘Class clsMAPI
‘*******************************************************
‘Algemene declaraties voor een email object.
‘*******************************************************
Dim objMySes As Object ‘Session object voor de MAPI sessiePublic Function SendMail(txtMailTo As String, Optional txtText As String, Optional txtSubject As String) As String
‘*******************************************************
‘Functie voor het versturen van een mailtje.
‘De returnwaarde is een string.
‘Als de string leeg is is de toevoeging succesvol geweest.
‘Als de string niet leeg is, dan bevat de string een
‘foutboodschap.
‘
‘LAATSTE WIJZIGING:
‘ Versie 1.0 augustus 2000 B. Stam
‘ Initiele versie van de functie
‘*******************************************************
On Error GoTo ErrorHandlerDim strMessage As String
Dim objRecip As Object
Dim objMes As Object‘*******************************************************
‘Ontvanger is verplicht.
‘*******************************************************
If txtMailTo = “” Then
strMessage = “The recipient of the mail is not valid or not given!”
GoTo ExitFunction
End If‘*******************************************************
‘Niet ingevulde parameters afhandelen.
‘*******************************************************
If IsMissing(txtText) Then
txtText = “”
End If
If IsMissing(txtSubject) Then
txtSubject = “”
End If‘*******************************************************
‘De boodschap zelf invullen.
‘*******************************************************
Set objMes = objMySes.Inbox.Messages.Add
With objMes
.Text = txtText
.Subject = txtSubject
End With‘*******************************************************
‘De ontvanger invullen
‘*******************************************************
Set objRecip = objMes.Recipients.Add
With objRecip
.Name = txtMailTo
.Resolve
‘.Send
End With‘*******************************************************
‘En nog even versturen.
‘*******************************************************
objMes.Update
objMes.Send ShowDialog:=FalseExitFunction:
If strMessage “” Then
SendMail = strMessage
Else
SendMail = “”
End If
Exit FunctionErrorHandler:
SendMail = Chr(10) & Chr(13) & “Errornumber: ” & CStr(Err.Number) & ” ”
SendMail = SendMail & “Errormessage: ” & Err.Description
Exit Function
End FunctionPrivate Sub Class_Initialize()
‘*******************************************************
‘Bij het instantieren van het object een MAPI sessie
‘openen.
‘Let op de profilename is afhankelijk van het mail
‘programma dat gebruikt wordt.
‘Als profilename weggelaten wordt, dan wordt er, indien
‘noodzakelijk, automatisch om gevraagd.
‘*******************************************************
Set objMySes = CreateObject(“MAPI.Session”)
If Not objMySes Is Nothing Then
objMySes.Logon ‘Als profilename niet gegeven hoeft te worden.
‘objMySes.Logon profileName:=”Microsoft Exchange”
End IfEnd Sub
Private Sub Class_Terminate()
‘*******************************************************
‘Als het object verwijderd wordt ook de MAPI sessie
‘verwijderd.
‘*******************************************************
objMySes.Logoff
End SubBart
Software Designer -
WSBart
AskWoody Lounger
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

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
-
Finding Microsoft Office 2021 product key
by
Kathy Stevens
16 minutes ago -
Over-the-Top solves it!
by
RetiredGeek
59 minutes ago -
To Susan – Woody Leonhard, the “Lionhearted”
by
Myst
8 hours ago -
Extracting Data From All Sheets
by
WSJon5
9 hours, 35 minutes ago -
Use wushowhide in Windows 11 24H2?
by
Tex265
9 hours, 44 minutes ago -
Hacktool:Win32/Winring0
by
Marvel Wars
9 hours, 31 minutes ago -
Microsoft Defender as Primary Security Question
by
blueboy714
10 hours, 11 minutes ago -
USB printers might print random text with the January 2025 preview update
by
Alex5723
12 hours, 14 minutes ago -
Google’s 10-year-old Chromecast is busted, but a fix is coming
by
Alex5723
21 hours, 50 minutes ago -
Expand the taskbar?
by
CWBillow
21 hours, 40 minutes ago -
Gregory Forrest “Woody” Leonhard (1951-2025)
by
Susan Bradley
27 minutes ago -
March 2025 updates are out
by
Susan Bradley
9 hours, 45 minutes ago -
Windows 11 Insider Preview build 26120.3380 released to DEV and BETA
by
joep517
1 day, 15 hours ago -
Update Firefox to prevent add-ons issues from root certificate expiration
by
Alex5723
1 day, 22 hours ago -
Latest Firefox requires Password on start up
by
Gordski
1 day, 17 hours ago -
Resolved : AutoCAD 2022 might not open after updating to 24H2
by
Alex5723
2 days, 11 hours ago -
Missing api-ms-win-core-libraryloader-11-2-1.dll
by
IreneLinda
1 day, 10 hours ago -
How Much Daylight have YOU Saved?
by
Nibbled To Death By Ducks
1 day, 13 hours ago -
A brief history of Windows Settings
by
Simon Bisson
1 day, 6 hours ago -
Thunderbolt is not just for monitors
by
Ben Myers
1 day, 5 hours ago -
Password Generators — Your first line of defense
by
Deanna McElveen
1 day, 10 hours ago -
AskWoody at the computer museum
by
Will Fastie
10 hours, 40 minutes ago -
Planning for the unexpected
by
Susan Bradley
1 day, 11 hours ago -
Which printer type is the better one to buy?
by
Bob99
2 days, 13 hours ago -
Upgrading the web server
by
Susan Bradley
2 days, 11 hours ago -
New Windows 11 24H2 Setup – Initial Win Update prevention settings?
by
Tex265
3 days, 6 hours ago -
Creating a Google account
by
DavidofIN
3 days, 5 hours ago -
Undocumented “backdoor” found in Bluetooth chip used by a billion devices
by
Alex5723
3 days, 11 hours ago -
Microsoft Considering AI Models to Replace OpenAI’s in Copilot
by
Alex5723
3 days, 22 hours ago -
AI *emergent misalignment*
by
Alex5723
4 days ago
Recent blog posts
Key Links
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.