A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

assigning items from a list of 1000 to a form field



 
 
Thread Tools Display Modes
  #1  
Old August 9th, 2004, 07:48 PM
sek0910
external usenet poster
 
Posts: n/a
Default assigning items from a list of 1000 to a form field

I have a list of 1000 discrete passwords (and that list
may grow from time to time). I'd like a system where
when I click a command button ("Generate Password"),
Access will take the first password from the list, insert
it in a text box on a form (that will then be stored in a
master table with the record for the particular user),
and then delete that password from the list so it can't
be used again.
Again thought?
Thanks, Steve
  #2  
Old August 10th, 2004, 02:24 PM
Tim Ferguson
external usenet poster
 
Posts: n/a
Default assigning items from a list of 1000 to a form field

"sek0910" wrote in
:

it in a text box on a form (that will then be stored in a
master table with the record for the particular user),
and then delete that password from the list so it can't
be used again.
Again thought?


public function GetNextPassword() as string

dim strSQL as String
dim strAnswer as string
dim db as Database

' get "next" password, whatever that means
strsql = "select top 1 ptext from passwords " & _
"order by ptext"

' handle to database
set db = currentdb()

' catch the null answer if there are no records left
' you could use a NZ() just as well
strAnswer = dfirst("ptext", strsql) & vbNullString

' was it okay?
If len(stranswer)0 then
' yes; delete if from the list
strsql = "delete from passwords " & _
"where ptext = """ & stranswer & """"

' brave here -- no error trapping!
db.execute strsql, dbfailonerror

End If

' return the password
GetNextPassword = strAnswer

End Function


Not tested, so usual caveats apply, but it's not very complicated.
Hope it helps


Tim F

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
auto entry into second table after update Tony New Users 13 July 9th, 2004 10:42 PM
Adding new field to existing form Joe Database Design 2 June 22nd, 2004 11:02 PM
Recordset in subform based on field in parent form Lyn General Discussion 15 June 14th, 2004 03:10 PM
display list box items per field selection on linked form neen Using Forms 7 June 14th, 2004 08:05 AM
NUMBERING the pages Bob New Users 7 June 14th, 2004 12:20 AM


All times are GMT +1. The time now is 01:40 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.