-
WSTim K.
AskWoody LoungerHi,
If you insist, here you go! Play with the code below. I use it with On_DblClick event of ID text box. The code will look up for the first unused ID found and fill in the ID text box for you. If no unused ID found, it will prompt you for the next running number.
Private Sub ID_DblClick(Cancel As Integer)
If Me.NewRecord Then
Dim strID As String, intMax As Integer, strMax As String
strID = FindUnusedID()
If IsNull(strID) Or strID = “” Then
If (MsgBox(“No more vacant ID left” & vbCrLf & _
“Do you want to add the next new ID?”, vbOKCancel, “No vacant ID”)) = vbOK Then
intMax = Val(DMax(“[ID]”, “tblID”)) + 1
Select Case intMax
Case Is < 10
strMax = "00" & CStr(intMax)
Case Is < 100
strMax = "0" & CStr(intMax)
Case Else
strMax = CStr(intMax)
End Select
Me.ID = strMax
Else
Cancel = True
Exit Sub
End If
Else
Me.ID = strID
End If
End IfEnd Sub
Function FindUnusedID()
Dim dbs As Database, rst As Recordset
Dim strID As String, intID As IntegerSet dbs = CurrentDb
' You have to open recordset as Dynaset to enable Sort
Set rst = dbs.OpenRecordset("tblID", dbOpenDynaset)With rst
If Not .EOF Then
' You have to sort the recordset beforehand
.Sort = "ID"
.MoveLast
.MoveFirst
For intID = 1 To .RecordCount
If Val(!ID) intID Then
Select Case Val(!ID) – 1
Case Is < 10
strID = "00" & CStr(intID)
Case Is < 100
strID = "0" & CStr(intID)
Case Else
strID = CStr(intID)
End SelectFindUnusedID = strID
'Debug.Print strID
Exit FunctionEnd If
.MoveNext
Next intID
End If
End WithSet rst = Nothing
Set dbs = NothingEnd Function
HTH.
Tim K. -
WSTim K.
AskWoody LoungerHi,
You have several ways to handle this. Do you plan to insert the URL into the table or just gather the URL when a use clicks a command button. If the latter, apply the code below and play with it to fit your need.
Private Sub cmdURL_Click()
Dim strURL as String
strURL = “www.ourwebsite.com/companypage.htm?compID=” & Me.compID
FollowHyperlink strURL
End SubHTH.
Tim K.
-
WSTim K.
AskWoody LoungerHi,
You have to add # to the link to make it valid as HyperLink. Try the code below.
Sub ValidateHyperLink()
Dim dbs As Database, rst As Recordset
Dim I As IntegerSet dbs = CurrentDb
Set rst = dbs.OpenRecordset(“tblPDFPath”)
If Not rst.EOF Then
rst.MoveFirst
For I = 1 To rst.RecordCount
rst.Edit
rst(“PDFPath”) = “Link to ‘” & rst(“PDFPath”) & “‘” & “#” & rst(“PDFPath”) & “#”
rst.Update
rst.MoveNext
Next I
End If
End SubIn the future, you can is the code below to facilitate your work.
‘ Set References to Microsoft Office 9.0 Object Library first
Private Sub Test()
Dim dbs As Database, rst As Recordset
Dim FS As FileSearch, FilePath As String, MyPath As String
Dim I As Integer, strFileName As StringSet dbs = CurrentDb
Set rst = dbs.OpenRecordset(“tblPDFPath”)
Set FS = Application.FileSearch
MyPath = “I:”
strFileName = “*.PDF”
With FS
.LookIn = MyPath
.SearchSubFolders = True
.FileName = strFileName
‘.FileName = “*.doc”
If .Execute() > 0 Then
For I = 1 To .FoundFiles.Count
Debug.Print .FoundFiles.Count
FilePath = .FoundFiles(I)
With rst ‘DoCmd.TransferText , , “tblPath”, .FoundFiles(i)
.AddNew
!PDFPath = FilePath
.Update
End With
Next I
Else
MsgBox “There were no files found.”
End IfEnd With
End Sub
Modify both to fit your need.
HTH.
Tim K. -
WSTim K.
AskWoody LoungerIf I understand your need well, I add the code below for the case 36
Case 36
‘ Not Ready Yet
Dim DateStart As Date, intDays As Integer, I As Integer
DateStart = DateSerial(Year(dteDate), Month(dteDate), 1)‘ Calculate how many days in this dteDate
intDays = DateSerial(Year(dteDate), Month(dteDate) + 1, Day(dteDate)) _
– DateSerial(Year(dteDate), Month(dteDate), Day(dteDate))‘ Show all days of the Type
For I = 1 To intDays
If DatePart(“w”, DateStart) = DayNum Then
MyDate = MyDate & DateStart & vbCrLf
End If
DateStart = DateStart + 1
Next ITim K.
-
WSTim K.
AskWoody LoungerHello Mark,
I have fixed the problem now after I studied the
http://support.microsoft.com/support/kb/ar…s/q244/2/64.asp
I followed the following paragraph:-
…Re-register the application by typing the path to the server in the Start and then Run dialog box, and then append /RegServer to the end of the line. Press OK. This should silently run the application and re-register it as a COM server. If the problem is with a missing registry key, this will typically correct it….Just typed this
“D:Program FilesAccess97OfficeWINWORD.EXE” /regserver
in the Run command line. And It worked.Thanks for your help anyhow.
Tim K.
-
WSTim K.
AskWoody LoungerHi Mark,
I did try both. They stoped at the same line I mentioned below. -
WSTim K.
AskWoody LoungerHi Mark,
It may sound ridicuous, but true.
Here’s the codeSub CodeRunningOutsideWord()
Dim wdApp As Word.Application
Dim docNew As Word.Document‘ Create new hidden instance of Word.
Set wdApp = New Word.Application
‘ Create a new document.
Set docNew = wdApp.Documents.Add
‘ Add text to document.
wdApp.Selection.TypeText “Four score and seven years ago”
‘ Display document name and count of words, and then close
‘ document without saving changes.
With docNew
MsgBox “‘” & .Name & “‘ contains ” & .Words.Count & ” words.”
.Close wdDoNotSaveChanges
End With
wdApp.Quit
Set wdApp = Nothing
End SubThe message error shows
Run-time error ‘429’
ActiveX component can’t create object.It stops at
Set docNew = wdApp.Documents.AddIt’s OK when I do the similar process to call Excel.
Any idea?
In the mean time, I am studying something at
http://support.microsoft.com/support/kb/ar…s/Q244/2/64.ASP
It seems very much like my problem.Thanks for your replies.
Tim K.
-
WSTim K.
AskWoody LoungerThank you, Ken.
I will study the code.Tim K.
-
WSTim K.
AskWoody LoungerIf you installed A97, you should find Solution.mdb in the samples folder. The code is working OK in this version.
I deal with the limited column by sending the data to pre-defined Excel file (format, print area). It works well.Tell me if you still need help.
Tim K.
Thailand -
WSTim K.
AskWoody LoungerI use the code below to deal with the problem.
Private Sub CEmail_AfterUpdate()
Dim strEmail As StringIf Len(Me.CEmail) > 0 Then
strEmail = Left(Me.CEmail, InStr(Me.CEmail, “#”) – 1)
strEmail = strEmail & “#mailto:” & strEmail & “#”
Me.CEmail = strEmail
End IfEnd Sub
HTH
Cheers!!
Tim K.
Thailand
![]() |
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 |

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
-
How start headers and page numbers on page 3?
by
Davidhs
29 minutes ago -
Attack on LexisNexis Risk Solutions exposes data on 300k +
by
Nibbled To Death By Ducks
3 hours, 18 minutes ago -
Windows 11 Insider Preview build 26200.5622 released to DEV
by
joep517
9 hours, 10 minutes ago -
Windows 11 Insider Preview build 26120.4230 (24H2) released to BETA
by
joep517
9 hours, 11 minutes ago -
MS Excel 2019 Now Prompts to Back Up With OneDrive
by
lmacri
52 minutes ago -
Firefox 139
by
Charlie
11 hours, 34 minutes ago -
Who knows what?
by
Will Fastie
4 hours, 16 minutes ago -
My top ten underappreciated features in Office
by
Peter Deegan
9 hours, 55 minutes ago -
WAU Manager — It’s your computer, you are in charge!
by
Deanna McElveen
4 hours, 18 minutes ago -
Misbehaving devices
by
Susan Bradley
12 hours, 3 minutes ago -
.NET 8.0 Desktop Runtime (v8.0.16) – Windows x86 Installer
by
WSmeyerbos
1 day, 15 hours ago -
Neowin poll : What do you plan to do on Windows 10 EOS
by
Alex5723
9 hours, 21 minutes ago -
May 31, 2025—KB5062170 (OS Builds 22621.5415 and 22631.5415 Out-of-band
by
Alex5723
1 day, 14 hours ago -
Discover the Best AI Tools for Everything
by
Alex5723
13 hours, 37 minutes ago -
Edge Seems To Be Gaining Weight
by
bbearren
1 day, 4 hours ago -
Rufus is available from the MSFT Store
by
PL1
1 day, 12 hours ago -
Microsoft : Ending USB-C® Port Confusion
by
Alex5723
2 days, 15 hours ago -
KB5061768 update for Intel vPro processor
by
drmark
15 hours, 24 minutes ago -
Outlook 365 classic has exhausted all shared resources
by
drmark
14 hours, 7 minutes ago -
My Simple Word 2010 Macro Is Not Working
by
mbennett555
2 days, 11 hours ago -
Office gets current release
by
Susan Bradley
2 days, 13 hours ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
4 days, 4 hours ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
3 days, 12 hours ago -
Stop the OneDrive defaults
by
CWBillow
4 days, 4 hours ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
4 days, 14 hours ago -
X Suspends Encrypted DMs
by
Alex5723
4 days, 16 hours ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
4 days, 17 hours ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
4 days, 17 hours ago -
OpenAI model sabotages shutdown code
by
Cybertooth
4 days, 18 hours ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
4 days, 6 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.