Richard
asked on
access INSERT into table
Private Sub Command397_Click()
Dim i As Integer
For i = Me.clientOneMobile To Me.clientTwoMobile
CurrentDb.Execute "INSERT INTO files(fileID)VALUES(" & i & ")"
Next i
End Sub
This is code which Inserts new records into Table called Files.
There is also a related table Clients.
Clients is the One and Files is the many.
How do I adapt the code to proi=vide new records for a specific Client, say, who has an ID of 5 (by way of unique index)
A WHERE addition to the code above?
Please help
Dim i As Integer
For i = Me.clientOneMobile To Me.clientTwoMobile
CurrentDb.Execute "INSERT INTO files(fileID)VALUES(" & i & ")"
Next i
End Sub
This is code which Inserts new records into Table called Files.
There is also a related table Clients.
Clients is the One and Files is the many.
How do I adapt the code to proi=vide new records for a specific Client, say, who has an ID of 5 (by way of unique index)
A WHERE addition to the code above?
Please help
Unless I'm reading it wrong, simply:
CurrentDb.Execute "INSERT INTO files(fileID)VALUES(5);"
orDim foo as Integer
foo = 5
CurrentDb.Execute "INSERT INTO files(fileID)VALUES(" & foo & ");"
ASKER
it is a number field...
this puts the new file records in but not the client number 5 in those records
any clues?
CurrentDb.Execute "INSERT INTO files(fileID,clientID)VALU ES(" & i & "," & 5 & ")"
this puts the new file records in but not the client number 5 in those records
any clues?
CurrentDb.Execute "INSERT INTO files(fileID,clientID)VALU
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
roger, lift off,
many many thanks
many many thanks
CurrentDb.Execute "INSERT INTO files(fileID, ClientID )VALUES(" & i & "," & MyClientID & ")"
If "ClienttID" is a text field, you'd have to do this:
CurrentDb.Execute "INSERT INTO files(fileID, ClientID )VALUES(" & i & ",'" & MyClientID & "')"