Shweta
Well-known Member
- Joined
- Jun 5, 2011
- Messages
- 514
Hello everyone,
I am trying to enter the random data in a table "tblProduct" using below VBA code. But it is throwing syntax error at highlighted line.
tlProduct has three fields i.e. P_ID as long, P_Name as text and P_Price as long
Kindly suggest.
Thanks in advance!
Regards,
Shweta
I am trying to enter the random data in a table "tblProduct" using below VBA code. But it is throwing syntax error at highlighted line.
tlProduct has three fields i.e. P_ID as long, P_Name as text and P_Price as long
Rich (BB code):
Sub insert_into_table()
Dim sSQL As String
For r = 1 To 10
x = Round(VBA.Rnd() * 100, 0)
sSQL = "INSERT INTO tblProduct VALUES(" & r & "," & ""Product- "" & r & "," & x & ")"
DoCmd.RunSQL sSQL
Next
End Sub
Kindly suggest.
Thanks in advance!
Regards,
Shweta
Last edited: