Ask Experts Questions for FREE Help !
Ask
    andy5179's Avatar
    andy5179 Posts: 5, Reputation: 1
    New Member
     
    #1

    Aug 18, 2005, 01:34 PM
    Trouble Updating Records Individually
    I'm trying to update a table in Microsoft Access with the following SQL:

    UPDATE tblLastLDAP, tblGenex1 SET tblGenex1.SURROGATEID = Left([tblLastLDAP]![Last],6) & Int((99-1+1)*Rnd()+1);

    I want the records to each be set to a number between 1 and 99 (+ the beginning info), but the result of the SQL above sets all of the records to the same number.

    How do I tell Access to process each record separately?

    Thanks!
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #2

    Aug 18, 2005, 06:29 PM
    Try:

    Left([tblLastLDAP]![Last],6) & Int((99-*Rnd())+1);
    andy5179's Avatar
    andy5179 Posts: 5, Reputation: 1
    New Member
     
    #3

    Aug 19, 2005, 05:59 AM
    This still updates all records at once, rather than updating them individually.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #4

    Aug 19, 2005, 09:08 AM
    Hmm, Ok, the next step is to use a custom function so you can initialize the number. This works, I tested it:

    Public Function NewNum(strLast As String) As String
    Randomize Len(strLast) ' Initialize random-number generator.
    NewNum = Left(strLast, 6) & Int((99 * Rnd) + 1)
    End Function

    In your Update query use:

    =NewNum([Last])

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

School records [ 2 Answers ]

How long are schools required to hold on to a student's withdrawl records. We have student withdrawl records formthe 1980's and 90's. Thanks

Updating 2 Wire Thermostat with Electronic Wireless [ 12 Answers ]

I've searched all the earlier Q&A and can't seem to find a matching problem. I am trying to replace an older 2 wire thermostat with a fancy, new wireless programmable thermostat. I am only running heat. I just want on/off and that's it. The furnace is a Burnham Series 2 Gas Boiler dated...

Updating text on HTML pages at run-time [ 7 Answers ]

I am novice web-site developer with previous programming experience. I am creating a very basic brochure-style web site based on tables with Frontpage 2003 as the development tool. I am having difficulty trying to figure out how to program into a script the logic to be able to update a web page...

Updating Printer Driver [ 12 Answers ]

I am trying to update my Lexmark X1185 All-In-One driver ( Ver. 1.0.0.0 to 2.0.2.2 ). I keep getting this error message:- C:\PROGRA~1\Symantec\S32EVNT1.DLL. An installableVirtual Device Driver failed Dll initialization. Choose " Close " to terminate the application. ( Close or Ignore ). If I...


View more questions Search