Dim strSQL As String
Dim Result As String
For iI = 0 To iTo - iFrom
strSQL = "Insert into Table(Field1,Field2,Field3, Field4, Field5) values(""" & Me.iFrom + iI & """,""" & _
Me.Field2 & """,""" & Me.Field3 & """,""" & Me.Field4 & """,""" & Me.Field 5 & """ )"
CurrentDb.Execute strSQL, dbFailOnError
Next
Dim strSQL As String
Dim Result As String
For iI = 0 To iTo - iFrom
Result = Me.iFrom + iI
If Result = DLookup("Field1", "Table", "Field1=" & Result) Then
'Debug.Print Result
MsgBox "this is already in use" & " " & Result
Cancel = True
Exit Sub
Else
strSQL = "Insert into Table(Field1,Field2,Field3, Field4, Field5) values(""" & Me.iFrom + iI & """,""" & _
Me.Field2 & """,""" & Me.Field3 & """,""" & Me.Field4 & """,""" & Me.Field5 & """ )"
CurrentDb.Execute strSQL, dbFailOnError
End If
Next
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE