|
-
Apr 9th, 2000, 05:26 PM
#1
Thread Starter
Junior Member
Dim lFrom as long, lTo as Long, l as Long
' check if values are entered
' code goes here
' read out entered values
lFrom = Clng(Val(Text1.Text))
lTo = Clng(Val(Text2.Text))
' validate if From < To
' code goes here
' loop from lFrom to lTo
For l = lFrom to lTo
' do something with l
' so that I can add all the
' numbers to the database
Next
My database is called carpet database and the table I wish to store the details in is called invoice numbers and the field is called invoice number...
If the user types in 100 and 300 as the two values I need to add these and all the numbers in between to my database for validation in other forms...
Can anybody help cos this is really streesing me out!!!
Cheers
Rhys
-
Apr 9th, 2000, 10:12 PM
#2
Frenzied Member
Don't get stressed...
firstly, don't use spaces in table or field names
You'll need a reference to DAO stuff
is this what you require?
Code:
Private Sub Command1_Click()
Dim l As Integer
Dim db As DAO.Database
Dim strSQL As String
Set db = DAO.OpenDatabase("C:\carpet Database.mdb")
' loop from lFrom to lTo
For l = lFrom To lTo
' do something with l
' so that I can add all the
' numbers to the database
strSQL = "INSERT INTO invoiceNumbers (invoiceNumber) VALUES(" & l & ");"
db.Execute strSQL
Next
db.Close
Set db = Nothing
End Sub
-
Apr 9th, 2000, 11:49 PM
#3
New Member
if you must use spaces in table or field name then when reference it surround it with spare brackets ie [my table].field1
FireBeast
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|