Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / August 2004

Tip: Looking for answers? Try searching our database.

assigning items from a list of 1000 to a form field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sek0910 - 09 Aug 2004 19:48 GMT
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
Tim Ferguson - 10 Aug 2004 14:24 GMT
> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.