When this update query runs the it does not recognize the value of integer variable vno in the WHERE field. A window opens labeled vno and asks for a value. If a value is entered the update complete and it goes to the next loop. what is need to make the content of vno available. The s syntax of the update string was copied from an update query with the vno replacing a numeric constant. While Cnt < Maxseq Rno = Int(Rnd() * 100) vno = Cnt SQL1 = "UPDATE StudentTable SET StudentTable.SortFld = Int(Rnd() * 100) WHERE ((StudentTable.SeqNO = vno))" DoCmd.RunSQL SQL1 Cnt = Cnt + 1 Wend -- Al C
Try concatenating the variable into the string: "...WHERE (StudentTable.SeqNO = " & vno & ")" -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "AL" <albert_c26@msn.com.(donotspan)> wrote in message news:93AC36C8-8D19-4F8F-81BA-B7D6B86A972F@microsoft.com... > When this update query runs the it does not recognize the value of integer > variable vno in the WHERE field. A window opens labeled vno and asks for > a > value. If a value is entered the update complete and it goes to the next > loop. what is need to make the content of vno available. The s syntax of > the update string was copied from an update query with the vno replacing a > numeric constant. > > While Cnt < Maxseq > Rno = Int(Rnd() * 100) > vno = Cnt > SQL1 = "UPDATE StudentTable SET StudentTable.SortFld = Int(Rnd() * 100) > WHERE ((StudentTable.SeqNO = vno))" > DoCmd.RunSQL SQL1 > Cnt = Cnt + 1 > Wend > -- > Al C