น่าจะคล้ายๆ อันนี้ เผื่อมีคนถนัดแวะมาตอบครับ
It needs to be a function not a Sub. So it should be:
Public Function RandNo() AS Integer
Dim iRNumber As Integer
Randomize
RandNo = Int((200 - 100 + 1) * Rnd + 100)
End Function
This will return the random number you want.
To add this to a table you could use code like:
Dim SQL As String
Dim i as Integer
For i = 1 to 5
strSQL = "INSERT INTO table (Field1, Field2, Filed3) " & _
"VALUES(" & RandNo() & ", " & RandNo() & ", " & RandNo() & ");"
CurrentDB.Execute strSQL, dbFailOnError
Next i
If you need further clarification on this feel free to ask.