Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-17-2019, 12:27 PM   #1
peskywinnets
Newly Registered User
 
Join Date: Feb 2014
Location: London, UK
Posts: 517
Thanks: 278
Thanked 5 Times in 5 Posts
peskywinnets is on a distinguished road
autokey shortcut insert an incrementing number

I seek a way of selecting a table field, then having a preset autokey (shortcut key) configured, that when pressed, runs a bit of VBA, that inserts a number (1 more than the last) into the selected field.

I know how to do autokeys.

I know how to store a number, recall it, increment it, then store it away again.

What I don't know is the mechanism of getting that number out of the VBA code (a variable)& into the clipboard.

A bit of googling revealed this...

https://www.access-programmers.co.uk...d.php?t=224088

specifically, this post...
___________________________________________

I have now got it workiny by using the following.
Quote:
Dim DataObj As New MSForms.DataObject
Dim S As String
S = Me.Stores_Address
DataObj.SetText S
DataObj.PutInClipboard
It didn't work earlier as FM20.dll was not referenced in tools / reference. As soon as I manually referenced this, it all started to work.

___________________________________________

...it's not working for me either...presumably I need to enable FM20.dll ...but I don't see it under references?

peskywinnets is offline   Reply With Quote
Old 07-17-2019, 12:36 PM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 3,631
Thanks: 38
Thanked 885 Times in 868 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: autokey shortcut insert an incrementing number

Hi. See if you can use TempVars.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 07-17-2019, 01:23 PM   #3
peskywinnets
Newly Registered User
 
Join Date: Feb 2014
Location: London, UK
Posts: 517
Thanks: 278
Thanked 5 Times in 5 Posts
peskywinnets is on a distinguished road
Re: autokey shortcut insert an incrementing number

Thanks...I googled tempvars, but there's a whole lot of learning for me there!

I've just managed to sort it ...all I had to do was use the 'Browse' option in references, to locate FM20.dll in windows/system32

Once done, this code works...

Code:
Dim obj As New DataObject
Dim txt As String

'Put some text inside a string variable
  txt = "This was copied to the clipboard using VBA!"

'Make object's text equal above string variable
  obj.SetText txt

'Place DataObject's text into the Clipboard
  obj.PutInClipboard

'Notify User
  MsgBox "There is now text copied to your clipboard!", vbInformation
original reference - https://www.thespreadsheetguru.com/b...-the-clipboard

peskywinnets is offline   Reply With Quote
Old 07-17-2019, 01:38 PM   #4
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 3,631
Thanks: 38
Thanked 885 Times in 868 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: autokey shortcut insert an incrementing number

Quote:
Originally Posted by peskywinnets View Post
Thanks...I googled tempvars, but there's a whole lot of learning for me there!

I've just managed to sort it ...all I had to do was use the 'Browse' option in references, to locate FM20.dll in windows/system32

Once done, this code works...

Code:
Dim obj As New DataObject
Dim txt As String

'Put some text inside a string variable
  txt = "This was copied to the clipboard using VBA!"

'Make object's text equal above string variable
  obj.SetText txt

'Place DataObject's text into the Clipboard
  obj.PutInClipboard

'Notify User
  MsgBox "There is now text copied to your clipboard!", vbInformation
original reference - https://www.thespreadsheetguru.com/b...-the-clipboard
Hi. Glad to hear you got it sorted out. Good luck with your project.

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Incrementing Number n_lou Modules & VBA 2 01-08-2010 05:52 AM
How do you populate a number field with an incrementing number? AccNovice Tables 5 08-15-2008 06:34 AM
incrementing number gregph Queries 1 01-16-2006 04:40 AM
Number incrementing terry518 Forms 6 04-13-2004 07:20 PM
Incrementing a number by 1 chrisjrice Forms 2 07-21-2003 12:25 AM




All times are GMT -8. The time now is 05:24 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World